mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: add support for dump-guest-core option
The "dump-guest-core' option is new option for the machine type (-machine pc,dump-guest-core) that controls whether the guest memory will be marked as dumpable. While testing this, I've found out that the value for the '-M' options is not parsed correctly when additional parameters are used. However, when '-machine' is used for the same options, it gets parsed as expected. That's why this patch also modifies the parsing and creating of the command line, so both '-M' and '-machine' are recognized. In QEMU's help there is only mention of the 'machine parameter now with no sign of the older '-M'.
This commit is contained in:
parent
78f3666fe9
commit
ff2d5a3d8a
@ -182,6 +182,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
|
|||||||
"seccomp-sandbox",
|
"seccomp-sandbox",
|
||||||
|
|
||||||
"reboot-timeout", /* 110 */
|
"reboot-timeout", /* 110 */
|
||||||
|
"dump-guest-core",
|
||||||
);
|
);
|
||||||
|
|
||||||
struct _qemuCaps {
|
struct _qemuCaps {
|
||||||
@ -1243,6 +1244,9 @@ qemuCapsComputeCmdFlags(const char *help,
|
|||||||
if (strstr(help, "-no-shutdown") && (version < 14000 || version > 15000))
|
if (strstr(help, "-no-shutdown") && (version < 14000 || version > 15000))
|
||||||
qemuCapsSet(caps, QEMU_CAPS_NO_SHUTDOWN);
|
qemuCapsSet(caps, QEMU_CAPS_NO_SHUTDOWN);
|
||||||
|
|
||||||
|
if (strstr(help, "dump-guest-core=on|off"))
|
||||||
|
qemuCapsSet(caps, QEMU_CAPS_DUMP_GUEST_CORE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handling of -incoming arg with varying features
|
* Handling of -incoming arg with varying features
|
||||||
* -incoming tcp (kvm >= 79, qemu >= 0.10.0)
|
* -incoming tcp (kvm >= 79, qemu >= 0.10.0)
|
||||||
|
@ -146,6 +146,7 @@ enum qemuCapsFlags {
|
|||||||
QEMU_CAPS_SCSI_DISK_WWN = 108, /* Is scsi-disk.wwn available? */
|
QEMU_CAPS_SCSI_DISK_WWN = 108, /* Is scsi-disk.wwn available? */
|
||||||
QEMU_CAPS_SECCOMP_SANDBOX = 109, /* -sandbox */
|
QEMU_CAPS_SECCOMP_SANDBOX = 109, /* -sandbox */
|
||||||
QEMU_CAPS_REBOOT_TIMEOUT = 110, /* -boot reboot-timeout */
|
QEMU_CAPS_REBOOT_TIMEOUT = 110, /* -boot reboot-timeout */
|
||||||
|
QEMU_CAPS_DUMP_GUEST_CORE = 111, /* dump-guest-core-parameter */
|
||||||
|
|
||||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||||
};
|
};
|
||||||
|
@ -4306,6 +4306,44 @@ no_memory:
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuBuildMachineArgStr(virCommandPtr cmd,
|
||||||
|
const virDomainDefPtr def,
|
||||||
|
qemuCapsPtr caps)
|
||||||
|
{
|
||||||
|
/* This should *never* be NULL, since we always provide
|
||||||
|
* a machine in the capabilities data for QEMU. So this
|
||||||
|
* check is just here as a safety in case the unexpected
|
||||||
|
* happens */
|
||||||
|
if (!def->os.machine)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!def->mem.dump_core) {
|
||||||
|
/* if no parameter to the machine type is needed, we still use
|
||||||
|
* '-M' to keep the most of the compatibility with older versions.
|
||||||
|
*/
|
||||||
|
virCommandAddArgList(cmd, "-M", def->os.machine, NULL);
|
||||||
|
} else {
|
||||||
|
if (!qemuCapsGet(caps, QEMU_CAPS_DUMP_GUEST_CORE)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
"%s", _("dump-guest-core is not available "
|
||||||
|
" with this QEMU binary"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* However, in case there is a parameter to be added, we need to
|
||||||
|
* use the "-machine" parameter because qemu is not parsing the
|
||||||
|
* "-M" correctly */
|
||||||
|
virCommandAddArg(cmd, "-machine");
|
||||||
|
virCommandAddArgFormat(cmd,
|
||||||
|
"%s,dump-guest-core=%s",
|
||||||
|
def->os.machine,
|
||||||
|
virDomainMemDumpTypeToString(def->mem.dump_core));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
qemuBuildSmpArgStr(const virDomainDefPtr def,
|
qemuBuildSmpArgStr(const virDomainDefPtr def,
|
||||||
qemuCapsPtr caps)
|
qemuCapsPtr caps)
|
||||||
@ -4498,12 +4536,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
virCommandAddArg(cmd, "-S"); /* freeze CPU */
|
virCommandAddArg(cmd, "-S"); /* freeze CPU */
|
||||||
|
|
||||||
/* This should *never* be NULL, since we always provide
|
if (qemuBuildMachineArgStr(cmd, def, caps) < 0)
|
||||||
* a machine in the capabilities data for QEMU. So this
|
goto error;
|
||||||
* check is just here as a safety in case the unexpected
|
|
||||||
* happens */
|
|
||||||
if (def->os.machine)
|
|
||||||
virCommandAddArgList(cmd, "-M", def->os.machine, NULL);
|
|
||||||
|
|
||||||
if (qemuBuildCpuArgStr(driver, def, emulator, caps,
|
if (qemuBuildCpuArgStr(driver, def, emulator, caps,
|
||||||
&ut, &cpu, &hasHwVirt, !!migrateFrom) < 0)
|
&ut, &cpu, &hasHwVirt, !!migrateFrom) < 0)
|
||||||
@ -8323,10 +8357,38 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
|
|||||||
}
|
}
|
||||||
if (STREQ(def->name, ""))
|
if (STREQ(def->name, ""))
|
||||||
VIR_FREE(def->name);
|
VIR_FREE(def->name);
|
||||||
} else if (STREQ(arg, "-M")) {
|
} else if (STREQ(arg, "-M") ||
|
||||||
|
STREQ(arg, "-machine")) {
|
||||||
|
char *params;
|
||||||
WANT_VALUE();
|
WANT_VALUE();
|
||||||
if (!(def->os.machine = strdup(val)))
|
params = strchr(val, ',');
|
||||||
goto no_memory;
|
if (params == NULL) {
|
||||||
|
if (!(def->os.machine = strdup(val)))
|
||||||
|
goto no_memory;
|
||||||
|
} else {
|
||||||
|
if (!(def->os.machine = strndup(val, params - val)))
|
||||||
|
goto no_memory;
|
||||||
|
|
||||||
|
while(params++) {
|
||||||
|
/* prepared for more "-machine" parameters */
|
||||||
|
char *tmp = params;
|
||||||
|
params = strchr(params, ',');
|
||||||
|
|
||||||
|
if (STRPREFIX(tmp, "dump-guest-core=")) {
|
||||||
|
tmp += strlen("dump-guest-core=");
|
||||||
|
if (params) {
|
||||||
|
tmp = strndup(tmp, params - tmp);
|
||||||
|
if (tmp == NULL)
|
||||||
|
goto no_memory;
|
||||||
|
}
|
||||||
|
def->mem.dump_core = virDomainMemDumpTypeFromString(tmp);
|
||||||
|
if (def->mem.dump_core <= 0)
|
||||||
|
def->mem.dump_core = VIR_DOMAIN_MEM_DUMP_DEFAULT;
|
||||||
|
if (params)
|
||||||
|
VIR_FREE(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (STREQ(arg, "-serial")) {
|
} else if (STREQ(arg, "-serial")) {
|
||||||
WANT_VALUE();
|
WANT_VALUE();
|
||||||
if (STRNEQ(val, "none")) {
|
if (STRNEQ(val, "none")) {
|
||||||
|
@ -846,7 +846,8 @@ mymain(void)
|
|||||||
QEMU_CAPS_VIRTIO_SCSI_PCI,
|
QEMU_CAPS_VIRTIO_SCSI_PCI,
|
||||||
QEMU_CAPS_BLOCKIO,
|
QEMU_CAPS_BLOCKIO,
|
||||||
QEMU_CAPS_SCSI_DISK_WWN,
|
QEMU_CAPS_SCSI_DISK_WWN,
|
||||||
QEMU_CAPS_SECCOMP_SANDBOX);
|
QEMU_CAPS_SECCOMP_SANDBOX,
|
||||||
|
QEMU_CAPS_DUMP_GUEST_CORE);
|
||||||
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user