Skip to content

Commit 52c31c2

Browse files
committed
Extract PKG_ABI from mutated string
1 parent 343074a commit 52c31c2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

debian/rules.d/0-common-vars.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ kmake = make ARCH=$(build_arch) \
201201
KERNELRELEASE=$(abi_release)-$(target_flavour) \
202202
CONFIG_DEBUG_SECTION_MISMATCH=y \
203203
KBUILD_BUILD_VERSION="$(uploadnum)" \
204-
CFLAGS_MODULE="-DPKG_ABI=$(abinum)" \
204+
CFLAGS_MODULE='-DPKG_ABI=\"$(abinum)\"' \
205205
PYTHON=$(PYTHON)
206206
ifneq ($(LOCAL_ENV_CC),)
207207
kmake += CC="$(LOCAL_ENV_CC)" DISTCC_HOSTS="$(LOCAL_ENV_DISTCC_HOSTS)"

include/asm-generic/mshyperv.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef _ASM_GENERIC_MSHYPERV_H
1919
#define _ASM_GENERIC_MSHYPERV_H
2020

21+
#include <linux/kernel.h>
2122
#include <linux/types.h>
2223
#include <linux/atomic.h>
2324
#include <linux/bitops.h>
@@ -120,7 +121,7 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
120121
* Preserve the ability to 'make deb-pkg' since PKG_ABI is provided
121122
* by the Ubuntu build rules.
122123
*/
123-
#define PKG_ABI 0
124+
#define PKG_ABI "0"
124125
#endif
125126

126127
/* Generate the guest OS identifier as described in the Hyper-V TLFS */
@@ -130,7 +131,15 @@ static inline u64 hv_generate_guest_id(u64 kernel_version)
130131

131132
guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
132133
guest_id |= (kernel_version << 16);
133-
guest_id |= PKG_ABI;
134+
/*
135+
* Delphix mutates the ABI number by appending a date and the commit hash. Strip it.
136+
*/
137+
char *token;
138+
char *pkg_abi_str = PKG_ABI;
139+
token = strsep(&pkg_abi_str, "-");
140+
unsigned long abi_number = simple_strtoul(token, NULL, 10);
141+
guest_id |= (abi_number << 8);
142+
134143

135144
return guest_id;
136145
}

0 commit comments

Comments
 (0)