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
This commit is contained in:
Daniel P. Berrange 2010-02-09 13:06:56 +00:00
parent d6126f764f
commit 910b019f93
6 changed files with 39 additions and 37 deletions

View File

@ -1108,12 +1108,12 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) {
return NULL; return NULL;
} }
static unsigned int qemudComputeCmdFlags(const char *help, static unsigned long long qemudComputeCmdFlags(const char *help,
unsigned int version, unsigned int version,
unsigned int is_kvm, unsigned int is_kvm,
unsigned int kvm_version) unsigned int kvm_version)
{ {
unsigned int flags = 0; unsigned long long flags = 0;
if (strstr(help, "-no-kqemu")) if (strstr(help, "-no-kqemu"))
flags |= QEMUD_CMD_FLAG_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) #define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0)
int qemudParseHelpStr(const char *help, int qemudParseHelpStr(const char *help,
unsigned int *flags, unsigned long long *flags,
unsigned int *version, unsigned int *version,
unsigned int *is_kvm, unsigned int *is_kvm,
unsigned int *kvm_version) unsigned int *kvm_version)
@ -1316,14 +1316,14 @@ fail:
int qemudExtractVersionInfo(const char *qemu, int qemudExtractVersionInfo(const char *qemu,
unsigned int *retversion, unsigned int *retversion,
unsigned int *retflags) { unsigned long long *retflags) {
const char *const qemuarg[] = { qemu, "-help", NULL }; const char *const qemuarg[] = { qemu, "-help", NULL };
const char *const qemuenv[] = { "LC_ALL=C", NULL }; const char *const qemuenv[] = { "LC_ALL=C", NULL };
pid_t child; pid_t child;
int newstdout = -1; int newstdout = -1;
int ret = -1, status; int ret = -1, status;
unsigned int version, is_kvm, kvm_version; unsigned int version, is_kvm, kvm_version;
unsigned int flags = 0; unsigned long long flags = 0;
if (retflags) if (retflags)
*retflags = 0; *retflags = 0;
@ -1425,7 +1425,7 @@ int
qemudNetworkIfaceConnect(virConnectPtr conn, qemudNetworkIfaceConnect(virConnectPtr conn,
struct qemud_driver *driver, struct qemud_driver *driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int qemuCmdFlags) unsigned long long qemuCmdFlags)
{ {
char *brname = NULL; char *brname = NULL;
int err; int err;
@ -1637,7 +1637,7 @@ no_memory:
int int
qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, int qemuCmdFlags) qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCmdFlags)
{ {
if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) {
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
@ -1720,7 +1720,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller)
static int static int
qemuAssignDeviceAliases(virDomainDefPtr def, int qemuCmdFlags) qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCmdFlags)
{ {
int i; int i;
@ -2188,7 +2188,7 @@ qemuSafeSerialParamValue(const char *value)
char * char *
qemuBuildDriveStr(virDomainDiskDefPtr disk, qemuBuildDriveStr(virDomainDiskDefPtr disk,
int bootable, int bootable,
int qemuCmdFlags) unsigned long long qemuCmdFlags)
{ {
virBuffer opt = VIR_BUFFER_INITIALIZER; virBuffer opt = VIR_BUFFER_INITIALIZER;
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
@ -3012,7 +3012,7 @@ no_memory:
static char * static char *
qemuBuildSmpArgStr(const virDomainDefPtr def, qemuBuildSmpArgStr(const virDomainDefPtr def,
int qemuCmdFlags) unsigned long long qemuCmdFlags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
@ -3055,7 +3055,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
virDomainDefPtr def, virDomainDefPtr def,
virDomainChrDefPtr monitor_chr, virDomainChrDefPtr monitor_chr,
int monitor_json, int monitor_json,
unsigned int qemuCmdFlags, unsigned long long qemuCmdFlags,
const char ***retargv, const char ***retargv,
const char ***retenv, const char ***retenv,
int **tapfds, int **tapfds,

View File

@ -170,10 +170,10 @@ virCapsPtr qemudCapsInit (virCapsPtr old_caps);
int qemudExtractVersion (struct qemud_driver *driver); int qemudExtractVersion (struct qemud_driver *driver);
int qemudExtractVersionInfo (const char *qemu, int qemudExtractVersionInfo (const char *qemu,
unsigned int *version, unsigned int *version,
unsigned int *flags); unsigned long long *qemuCmdFlags);
int qemudParseHelpStr (const char *str, int qemudParseHelpStr (const char *str,
unsigned int *flags, unsigned long long *qemuCmdFlags,
unsigned int *version, unsigned int *version,
unsigned int *is_kvm, unsigned int *is_kvm,
unsigned int *kvm_version); unsigned int *kvm_version);
@ -183,7 +183,7 @@ int qemudBuildCommandLine (virConnectPtr conn,
virDomainDefPtr def, virDomainDefPtr def,
virDomainChrDefPtr monitor_chr, virDomainChrDefPtr monitor_chr,
int monitor_json, int monitor_json,
unsigned int qemuCmdFlags, unsigned long long qemuCmdFlags,
const char ***retargv, const char ***retargv,
const char ***retenv, const char ***retenv,
int **tapfds, int **tapfds,
@ -203,12 +203,12 @@ char * qemuBuildNicStr(virDomainNetDefPtr net,
/* Current, best practice */ /* Current, best practice */
char * qemuBuildNicDevStr(virDomainNetDefPtr net, char * qemuBuildNicDevStr(virDomainNetDefPtr net,
int qemuCmdFlags); int vlan);
/* Both legacy & current support */ /* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk, char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
int bootable, int bootable,
int qemuCmdFlags); unsigned long long qemuCmdFlags);
/* Current, best practice */ /* Current, best practice */
char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk); char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk);
@ -241,7 +241,7 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev);
int qemudNetworkIfaceConnect (virConnectPtr conn, int qemudNetworkIfaceConnect (virConnectPtr conn,
struct qemud_driver *driver, struct qemud_driver *driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int qemuCmdFlags); unsigned long long qemuCmdFlags);
int qemudProbeMachineTypes (const char *binary, int qemudProbeMachineTypes (const char *binary,
virCapsGuestMachinePtr **machines, virCapsGuestMachinePtr **machines,
@ -278,7 +278,7 @@ int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr ad
int qemuDomainNetVLAN(virDomainNetDefPtr def); int qemuDomainNetVLAN(virDomainNetDefPtr def);
int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx); 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 qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr net, int idx);
int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller); int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller);

View File

@ -2508,7 +2508,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
struct stat sb; struct stat sb;
int *tapfds = NULL; int *tapfds = NULL;
int ntapfds = 0; int ntapfds = 0;
unsigned int qemuCmdFlags; unsigned long long qemuCmdFlags;
fd_set keepfd; fd_set keepfd;
const char *emulator; const char *emulator;
pid_t child; pid_t child;
@ -4691,7 +4691,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
virDomainChrDef monConfig; virDomainChrDef monConfig;
const char *emulator; const char *emulator;
unsigned int qemuCmdFlags; unsigned long long qemuCmdFlags;
struct stat sb; struct stat sb;
const char **retargv = NULL; const char **retargv = NULL;
const char **retenv = NULL; const char **retenv = NULL;
@ -5563,7 +5563,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
struct qemud_driver *driver, struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainNetDefPtr net, virDomainNetDefPtr net,
unsigned int qemuCmdFlags) unsigned long long qemuCmdFlags)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
char *tapfd_name = NULL; char *tapfd_name = NULL;
@ -5877,7 +5877,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
struct qemud_driver *driver = dom->conn->privateData; struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainDeviceDefPtr dev = NULL; virDomainDeviceDefPtr dev = NULL;
unsigned int qemuCmdFlags; unsigned long long qemuCmdFlags;
virCgroupPtr cgroup = NULL; virCgroupPtr cgroup = NULL;
int ret = -1; int ret = -1;
@ -7408,7 +7408,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
int ret = -1; int ret = -1;
int internalret; int internalret;
char *unixfile = NULL; char *unixfile = NULL;
unsigned int qemuCmdFlags; unsigned long long qemuCmdFlags;
struct qemuStreamMigFile *qemust = NULL; struct qemuStreamMigFile *qemust = NULL;
qemuDriverLock(driver); qemuDriverLock(driver);
@ -7851,7 +7851,7 @@ static int doTunnelMigrate(virDomainPtr dom,
virStreamPtr st = NULL; virStreamPtr st = NULL;
char *unixfile = NULL; char *unixfile = NULL;
int internalret; int internalret;
unsigned int qemuCmdFlags; unsigned long long qemuCmdFlags;
int status; int status;
unsigned long long transferred, remaining, total; unsigned long long transferred, remaining, total;

View File

@ -75,7 +75,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
struct testInfo { struct testInfo {
const char *name; const char *name;
int extraFlags; unsigned long long extraFlags;
const char *migrateFrom; const char *migrateFrom;
}; };

View File

@ -12,10 +12,10 @@
struct testInfo { struct testInfo {
const char *name; const char *name;
unsigned flags; unsigned long long flags;
unsigned version; unsigned int version;
unsigned is_kvm; unsigned int is_kvm;
unsigned kvm_version; unsigned int kvm_version;
}; };
static char *progname; static char *progname;
@ -41,7 +41,8 @@ static int testHelpStrParsing(const void *data)
char path[PATH_MAX]; char path[PATH_MAX];
char helpStr[MAX_HELP_OUTPUT_SIZE]; char helpStr[MAX_HELP_OUTPUT_SIZE];
char *help = &(helpStr[0]); 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); snprintf(path, PATH_MAX, "%s/qemuhelpdata/%s", abs_srcdir, info->name);
@ -52,7 +53,7 @@ static int testHelpStrParsing(const void *data)
return -1; return -1;
if (flags != info->flags) { 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); flags, info->flags);
if (getenv("VIR_TEST_DEBUG")) if (getenv("VIR_TEST_DEBUG"))

View File

@ -24,7 +24,7 @@ static struct qemud_driver driver;
static int testCompareXMLToArgvFiles(const char *xml, static int testCompareXMLToArgvFiles(const char *xml,
const char *cmd, const char *cmd,
int extraFlags, unsigned long long extraFlags,
const char *migrateFrom) { const char *migrateFrom) {
char argvData[MAX_FILE]; char argvData[MAX_FILE];
char *expectargv = &(argvData[0]); char *expectargv = &(argvData[0]);
@ -32,7 +32,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
const char **argv = NULL; const char **argv = NULL;
const char **qenv = NULL; const char **qenv = NULL;
const char **tmp = NULL; const char **tmp = NULL;
int ret = -1, len, flags; int ret = -1, len;
unsigned long long flags;
virDomainDefPtr vmdef = NULL; virDomainDefPtr vmdef = NULL;
virDomainChrDef monitor_chr; virDomainChrDef monitor_chr;
@ -142,7 +143,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
struct testInfo { struct testInfo {
const char *name; const char *name;
int extraFlags; unsigned long long extraFlags;
const char *migrateFrom; const char *migrateFrom;
}; };