mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
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:
parent
d6126f764f
commit
910b019f93
@ -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;
|
||||
|
||||
@ -2188,7 +2188,7 @@ qemuSafeSerialParamValue(const char *value)
|
||||
char *
|
||||
qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
int bootable,
|
||||
int qemuCmdFlags)
|
||||
unsigned long long qemuCmdFlags)
|
||||
{
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
||||
@ -3012,7 +3012,7 @@ no_memory:
|
||||
|
||||
static char *
|
||||
qemuBuildSmpArgStr(const virDomainDefPtr def,
|
||||
int qemuCmdFlags)
|
||||
unsigned long long qemuCmdFlags)
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
@ -3055,7 +3055,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,
|
||||
|
@ -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,
|
||||
@ -203,12 +203,12 @@ char * qemuBuildNicStr(virDomainNetDefPtr net,
|
||||
|
||||
/* 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(virDomainDiskDefPtr disk);
|
||||
@ -241,7 +241,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,
|
||||
@ -278,7 +278,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);
|
||||
|
||||
|
@ -2508,7 +2508,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;
|
||||
@ -4691,7 +4691,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;
|
||||
@ -5563,7 +5563,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;
|
||||
@ -5877,7 +5877,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;
|
||||
|
||||
@ -7408,7 +7408,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);
|
||||
@ -7851,7 +7851,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;
|
||||
|
||||
|
@ -75,7 +75,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
|
||||
struct testInfo {
|
||||
const char *name;
|
||||
int extraFlags;
|
||||
unsigned long long extraFlags;
|
||||
const char *migrateFrom;
|
||||
};
|
||||
|
||||
|
@ -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"))
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user