[libvirt] [PATCH] Convert qemu command line flags to 64-bit int

The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int * src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags --- src/qemu/qemu_conf.c | 28 ++++++++++++++-------------- src/qemu/qemu_conf.h | 14 +++++++------- src/qemu/qemu_driver.c | 12 ++++++------ tests/qemuargv2xmltest.c | 2 +- tests/qemuhelptest.c | 13 +++++++------ tests/qemuxml2argvtest.c | 7 ++++--- 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 257b4a4..e3769c8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1108,12 +1108,12 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) { return NULL; } -static unsigned int qemudComputeCmdFlags(const char *help, - unsigned int version, - unsigned int is_kvm, - unsigned int kvm_version) +static unsigned long long qemudComputeCmdFlags(const char *help, + unsigned int version, + unsigned int is_kvm, + unsigned int kvm_version) { - unsigned int flags = 0; + unsigned long long flags = 0; if (strstr(help, "-no-kqemu")) flags |= QEMUD_CMD_FLAG_KQEMU; @@ -1236,7 +1236,7 @@ static unsigned int qemudComputeCmdFlags(const char *help, #define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0) int qemudParseHelpStr(const char *help, - unsigned int *flags, + unsigned long long *flags, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version) @@ -1316,14 +1316,14 @@ fail: int qemudExtractVersionInfo(const char *qemu, unsigned int *retversion, - unsigned int *retflags) { + unsigned long long *retflags) { const char *const qemuarg[] = { qemu, "-help", NULL }; const char *const qemuenv[] = { "LC_ALL=C", NULL }; pid_t child; int newstdout = -1; int ret = -1, status; unsigned int version, is_kvm, kvm_version; - unsigned int flags = 0; + unsigned long long flags = 0; if (retflags) *retflags = 0; @@ -1425,7 +1425,7 @@ int qemudNetworkIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { char *brname = NULL; int err; @@ -1637,7 +1637,7 @@ no_memory: int -qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, int qemuCmdFlags) +qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCmdFlags) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) @@ -1720,7 +1720,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller) static int -qemuAssignDeviceAliases(virDomainDefPtr def, int qemuCmdFlags) +qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCmdFlags) { int i; @@ -2189,7 +2189,7 @@ qemuSafeSerialParamValue(virConnectPtr conn, char * qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); @@ -3017,7 +3017,7 @@ no_memory: static char * qemuBuildSmpArgStr(const virDomainDefPtr def, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -3057,7 +3057,7 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainDefPtr def, virDomainChrDefPtr monitor_chr, int monitor_json, - unsigned int qemuCmdFlags, + unsigned long long qemuCmdFlags, const char ***retargv, const char ***retenv, int **tapfds, diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5525b6c..f6397b7 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -170,10 +170,10 @@ virCapsPtr qemudCapsInit (virCapsPtr old_caps); int qemudExtractVersion (struct qemud_driver *driver); int qemudExtractVersionInfo (const char *qemu, unsigned int *version, - unsigned int *flags); + unsigned long long *qemuCmdFlags); int qemudParseHelpStr (const char *str, - unsigned int *flags, + unsigned long long *qemuCmdFlags, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version); @@ -183,7 +183,7 @@ int qemudBuildCommandLine (virConnectPtr conn, virDomainDefPtr def, virDomainChrDefPtr monitor_chr, int monitor_json, - unsigned int qemuCmdFlags, + unsigned long long qemuCmdFlags, const char ***retargv, const char ***retenv, int **tapfds, @@ -205,12 +205,12 @@ char * qemuBuildNicStr(virConnectPtr conn, /* Current, best practice */ char * qemuBuildNicDevStr(virDomainNetDefPtr net, - int qemuCmdFlags); + int vlan); /* Both legacy & current support */ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - int qemuCmdFlags); + unsigned long long qemuCmdFlags); /* Current, best practice */ char * qemuBuildDriveDevStr(virConnectPtr conn, @@ -244,7 +244,7 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev); int qemudNetworkIfaceConnect (virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - int qemuCmdFlags); + unsigned long long qemuCmdFlags); int qemudProbeMachineTypes (const char *binary, virCapsGuestMachinePtr **machines, @@ -283,7 +283,7 @@ int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr ad int qemuDomainNetVLAN(virDomainNetDefPtr def); int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx); -int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, int qemuCmdFlags); +int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCmdFlags); int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr net, int idx); int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4374291..54d33cd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2520,7 +2520,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, struct stat sb; int *tapfds = NULL; int ntapfds = 0; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; fd_set keepfd; const char *emulator; pid_t child; @@ -4707,7 +4707,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, virDomainDefPtr def = NULL; virDomainChrDef monConfig; const char *emulator; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; struct stat sb; const char **retargv = NULL; const char **retenv = NULL; @@ -5586,7 +5586,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, virDomainNetDefPtr net, - unsigned int qemuCmdFlags) + unsigned long long qemuCmdFlags) { qemuDomainObjPrivatePtr priv = vm->privateData; char *tapfd_name = NULL; @@ -5901,7 +5901,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDeviceDefPtr dev = NULL; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; virCgroupPtr cgroup = NULL; int ret = -1; @@ -7437,7 +7437,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, int ret = -1; int internalret; char *unixfile = NULL; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; struct qemuStreamMigFile *qemust = NULL; qemuDriverLock(driver); @@ -7884,7 +7884,7 @@ static int doTunnelMigrate(virDomainPtr dom, virStreamPtr st = NULL; char *unixfile = NULL; int internalret; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; int status; unsigned long long transferred, remaining, total; diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 1f1914b..c125a34 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -75,7 +75,7 @@ static int testCompareXMLToArgvFiles(const char *xml, struct testInfo { const char *name; - int extraFlags; + unsigned long long extraFlags; const char *migrateFrom; }; diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 34a6048..0f2b509 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -12,10 +12,10 @@ struct testInfo { const char *name; - unsigned flags; - unsigned version; - unsigned is_kvm; - unsigned kvm_version; + unsigned long long flags; + unsigned int version; + unsigned int is_kvm; + unsigned int kvm_version; }; static char *progname; @@ -41,7 +41,8 @@ static int testHelpStrParsing(const void *data) char path[PATH_MAX]; char helpStr[MAX_HELP_OUTPUT_SIZE]; char *help = &(helpStr[0]); - unsigned flags, version, is_kvm, kvm_version; + unsigned int version, is_kvm, kvm_version; + unsigned long long flags; snprintf(path, PATH_MAX, "%s/qemuhelpdata/%s", abs_srcdir, info->name); @@ -52,7 +53,7 @@ static int testHelpStrParsing(const void *data) return -1; if (flags != info->flags) { - fprintf(stderr, "Computed flags do not match: got 0x%x, expected 0x%x\n", + fprintf(stderr, "Computed flags do not match: got 0x%llx, expected 0x%llx\n", flags, info->flags); if (getenv("VIR_TEST_DEBUG")) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 67dc47e..f4908b8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -24,7 +24,7 @@ static struct qemud_driver driver; static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, - int extraFlags, + unsigned long long extraFlags, const char *migrateFrom) { char argvData[MAX_FILE]; char *expectargv = &(argvData[0]); @@ -32,7 +32,8 @@ static int testCompareXMLToArgvFiles(const char *xml, const char **argv = NULL; const char **qenv = NULL; const char **tmp = NULL; - int ret = -1, len, flags; + int ret = -1, len; + unsigned long long flags; virDomainDefPtr vmdef = NULL; virDomainChrDef monitor_chr; @@ -142,7 +143,7 @@ static int testCompareXMLToArgvFiles(const char *xml, struct testInfo { const char *name; - int extraFlags; + unsigned long long extraFlags; const char *migrateFrom; }; -- 1.6.6

2010/2/9 Daniel P. Berrange <berrange@redhat.com>:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags ---
ACK. Matthias

On Tue, Feb 09, 2010 at 07:04:24PM +0000, Daniel P. Berrange wrote:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags --- src/qemu/qemu_conf.c | 28 ++++++++++++++-------------- src/qemu/qemu_conf.h | 14 +++++++------- src/qemu/qemu_driver.c | 12 ++++++------ tests/qemuargv2xmltest.c | 2 +- tests/qemuhelptest.c | 13 +++++++------ tests/qemuxml2argvtest.c | 7 ++++--- 6 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 257b4a4..e3769c8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1108,12 +1108,12 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) { return NULL; }
-static unsigned int qemudComputeCmdFlags(const char *help, - unsigned int version, - unsigned int is_kvm, - unsigned int kvm_version) +static unsigned long long qemudComputeCmdFlags(const char *help, + unsigned int version, + unsigned int is_kvm, + unsigned int kvm_version) { - unsigned int flags = 0; + unsigned long long flags = 0;
if (strstr(help, "-no-kqemu")) flags |= QEMUD_CMD_FLAG_KQEMU; @@ -1236,7 +1236,7 @@ static unsigned int qemudComputeCmdFlags(const char *help, #define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0)
int qemudParseHelpStr(const char *help, - unsigned int *flags, + unsigned long long *flags, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version) @@ -1316,14 +1316,14 @@ fail:
int qemudExtractVersionInfo(const char *qemu, unsigned int *retversion, - unsigned int *retflags) { + unsigned long long *retflags) { const char *const qemuarg[] = { qemu, "-help", NULL }; const char *const qemuenv[] = { "LC_ALL=C", NULL }; pid_t child; int newstdout = -1; int ret = -1, status; unsigned int version, is_kvm, kvm_version; - unsigned int flags = 0; + unsigned long long flags = 0;
if (retflags) *retflags = 0; @@ -1425,7 +1425,7 @@ int qemudNetworkIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { char *brname = NULL; int err; @@ -1637,7 +1637,7 @@ no_memory:
int -qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, int qemuCmdFlags) +qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCmdFlags) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) @@ -1720,7 +1720,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller)
static int -qemuAssignDeviceAliases(virDomainDefPtr def, int qemuCmdFlags) +qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCmdFlags) { int i;
@@ -2189,7 +2189,7 @@ qemuSafeSerialParamValue(virConnectPtr conn, char * qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); @@ -3017,7 +3017,7 @@ no_memory:
static char * qemuBuildSmpArgStr(const virDomainDefPtr def, - int qemuCmdFlags) + unsigned long long qemuCmdFlags) { virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -3057,7 +3057,7 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainDefPtr def, virDomainChrDefPtr monitor_chr, int monitor_json, - unsigned int qemuCmdFlags, + unsigned long long qemuCmdFlags, const char ***retargv, const char ***retenv, int **tapfds, diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5525b6c..f6397b7 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -170,10 +170,10 @@ virCapsPtr qemudCapsInit (virCapsPtr old_caps); int qemudExtractVersion (struct qemud_driver *driver); int qemudExtractVersionInfo (const char *qemu, unsigned int *version, - unsigned int *flags); + unsigned long long *qemuCmdFlags);
int qemudParseHelpStr (const char *str, - unsigned int *flags, + unsigned long long *qemuCmdFlags, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version); @@ -183,7 +183,7 @@ int qemudBuildCommandLine (virConnectPtr conn, virDomainDefPtr def, virDomainChrDefPtr monitor_chr, int monitor_json, - unsigned int qemuCmdFlags, + unsigned long long qemuCmdFlags, const char ***retargv, const char ***retenv, int **tapfds, @@ -205,12 +205,12 @@ char * qemuBuildNicStr(virConnectPtr conn,
/* Current, best practice */ char * qemuBuildNicDevStr(virDomainNetDefPtr net, - int qemuCmdFlags); + int vlan);
/* Both legacy & current support */ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - int qemuCmdFlags); + unsigned long long qemuCmdFlags);
/* Current, best practice */ char * qemuBuildDriveDevStr(virConnectPtr conn, @@ -244,7 +244,7 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev); int qemudNetworkIfaceConnect (virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - int qemuCmdFlags); + unsigned long long qemuCmdFlags);
int qemudProbeMachineTypes (const char *binary, virCapsGuestMachinePtr **machines, @@ -283,7 +283,7 @@ int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr ad
int qemuDomainNetVLAN(virDomainNetDefPtr def); int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx); -int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, int qemuCmdFlags); +int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCmdFlags); int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr net, int idx); int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4374291..54d33cd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2520,7 +2520,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, struct stat sb; int *tapfds = NULL; int ntapfds = 0; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; fd_set keepfd; const char *emulator; pid_t child; @@ -4707,7 +4707,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, virDomainDefPtr def = NULL; virDomainChrDef monConfig; const char *emulator; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; struct stat sb; const char **retargv = NULL; const char **retenv = NULL; @@ -5586,7 +5586,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, virDomainNetDefPtr net, - unsigned int qemuCmdFlags) + unsigned long long qemuCmdFlags) { qemuDomainObjPrivatePtr priv = vm->privateData; char *tapfd_name = NULL; @@ -5901,7 +5901,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDeviceDefPtr dev = NULL; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; virCgroupPtr cgroup = NULL; int ret = -1;
@@ -7437,7 +7437,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, int ret = -1; int internalret; char *unixfile = NULL; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; struct qemuStreamMigFile *qemust = NULL;
qemuDriverLock(driver); @@ -7884,7 +7884,7 @@ static int doTunnelMigrate(virDomainPtr dom, virStreamPtr st = NULL; char *unixfile = NULL; int internalret; - unsigned int qemuCmdFlags; + unsigned long long qemuCmdFlags; int status; unsigned long long transferred, remaining, total;
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 1f1914b..c125a34 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -75,7 +75,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
struct testInfo { const char *name; - int extraFlags; + unsigned long long extraFlags; const char *migrateFrom; };
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 34a6048..0f2b509 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -12,10 +12,10 @@
struct testInfo { const char *name; - unsigned flags; - unsigned version; - unsigned is_kvm; - unsigned kvm_version; + unsigned long long flags; + unsigned int version; + unsigned int is_kvm; + unsigned int kvm_version; };
static char *progname; @@ -41,7 +41,8 @@ static int testHelpStrParsing(const void *data) char path[PATH_MAX]; char helpStr[MAX_HELP_OUTPUT_SIZE]; char *help = &(helpStr[0]); - unsigned flags, version, is_kvm, kvm_version; + unsigned int version, is_kvm, kvm_version; + unsigned long long flags;
snprintf(path, PATH_MAX, "%s/qemuhelpdata/%s", abs_srcdir, info->name);
@@ -52,7 +53,7 @@ static int testHelpStrParsing(const void *data) return -1;
if (flags != info->flags) { - fprintf(stderr, "Computed flags do not match: got 0x%x, expected 0x%x\n", + fprintf(stderr, "Computed flags do not match: got 0x%llx, expected 0x%llx\n", flags, info->flags);
if (getenv("VIR_TEST_DEBUG")) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 67dc47e..f4908b8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -24,7 +24,7 @@ static struct qemud_driver driver;
static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, - int extraFlags, + unsigned long long extraFlags, const char *migrateFrom) { char argvData[MAX_FILE]; char *expectargv = &(argvData[0]); @@ -32,7 +32,8 @@ static int testCompareXMLToArgvFiles(const char *xml, const char **argv = NULL; const char **qenv = NULL; const char **tmp = NULL; - int ret = -1, len, flags; + int ret = -1, len; + unsigned long long flags; virDomainDefPtr vmdef = NULL; virDomainChrDef monitor_chr;
@@ -142,7 +143,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
struct testInfo { const char *name; - int extraFlags; + unsigned long long extraFlags; const char *migrateFrom; };
ACK, that was something I was about to look at :-) hopefully the enum definition for the flags will allow to go over 32 bits too, I think the patch should also change all the QEMUD_CMD_FLAG_ in /src/qemu/qemu_conf.h to be redefined from (1 << x) into (1UUL << x), Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

2010/2/10 Daniel Veillard <veillard@redhat.com>:
On Tue, Feb 09, 2010 at 07:04:24PM +0000, Daniel P. Berrange wrote:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags ---
ACK, that was something I was about to look at :-) hopefully the enum definition for the flags will allow to go over 32 bits too, I think the patch should also change all the QEMUD_CMD_FLAG_ in /src/qemu/qemu_conf.h to be redefined from (1 << x) into (1UUL << x),
Daniel
I missed the fact that the flags are defined as enum members. This maybe an issue. IIRC enum members are ints. We should test this to make sure it works as expected on 32bit and 64bit systems. Matthias

On Wed, Feb 10, 2010 at 11:45:45AM +0100, Matthias Bolte wrote:
2010/2/10 Daniel Veillard <veillard@redhat.com>:
On Tue, Feb 09, 2010 at 07:04:24PM +0000, Daniel P. Berrange wrote:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags ---
ACK, that was something I was about to look at :-) hopefully the enum definition for the flags will allow to go over 32 bits too, I think the patch should also change all the QEMUD_CMD_FLAG_ in /src/qemu/qemu_conf.h to be redefined from (1 << x) into (1UUL << x),
Daniel
I missed the fact that the flags are defined as enum members. This maybe an issue. IIRC enum members are ints. We should test this to make sure it works as expected on 32bit and 64bit systems.
We're not ever declaring instances of the enum type, only using it as a convenient way to define the constants. So provided we add '1UUL' as DV suggests, we should be fine. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Feb 10, 2010 at 10:51:31AM +0000, Daniel P. Berrange wrote:
On Wed, Feb 10, 2010 at 11:45:45AM +0100, Matthias Bolte wrote:
2010/2/10 Daniel Veillard <veillard@redhat.com>:
On Tue, Feb 09, 2010 at 07:04:24PM +0000, Daniel P. Berrange wrote:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags ---
ACK, that was something I was about to look at :-) hopefully the enum definition for the flags will allow to go over 32 bits too, I think the patch should also change all the QEMUD_CMD_FLAG_ in /src/qemu/qemu_conf.h to be redefined from (1 << x) into (1UUL << x),
Daniel
I missed the fact that the flags are defined as enum members. This maybe an issue. IIRC enum members are ints. We should test this to make sure it works as expected on 32bit and 64bit systems.
We're not ever declaring instances of the enum type, only using it as a convenient way to define the constants. So provided we add '1UUL' as DV suggests, we should be fine.
I just tested and confirmed that on 32-bit when we start adding values to the enum >= 32 we will need to make it use 1ULL. The compiler actually identifies & warns about this so you can't miss it :-) Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Feb 10, 2010 at 11:45:45AM +0100, Matthias Bolte wrote:
2010/2/10 Daniel Veillard <veillard@redhat.com>:
On Tue, Feb 09, 2010 at 07:04:24PM +0000, Daniel P. Berrange wrote:
The QEMU flags are commonly stored as a signed or unsigned int, allowing only 31 flags. This limit is rather close, so to aid future patches, change it to a 64-bit int
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c: Use 'unsigned long long' for QEMU flags ---
ACK, that was something I was about to look at :-) hopefully the enum definition for the flags will allow to go over 32 bits too, I think the patch should also change all the QEMUD_CMD_FLAG_ in /src/qemu/qemu_conf.h to be redefined from (1 << x) into (1UUL << x),
Daniel
I missed the fact that the flags are defined as enum members. This maybe an issue. IIRC enum members are ints. We should test this to make sure it works as expected on 32bit and 64bit systems.
or just convert all for them as #define ! We don't use any of the properties of an enum anyway, it's just bitfield enumerations, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Matthias Bolte