mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: simplify use of HAVE_YAJL
Rather than making all clients of monitor commands that are JSON-only check whether yajl support was compiled in, it is simpler to just avoid setting the capability bit up front if we can't use the capability. * src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags): Only set capability bit if we also have yajl library to use it. * src/qemu/qemu_driver.c (qemuDomainReboot): Drop #ifdefs. * src/qemu/qemu_process.c (qemuProcessStart): Likewise. * tests/qemuhelptest.c (testHelpStrParsing): Pass test even without yajl. * tests/qemuxml2argvtest.c (mymain): Simplify use of json flag. * tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-*.args: Update expected results to match.
This commit is contained in:
parent
cfa61a950a
commit
6889f33e8b
@ -1060,8 +1060,10 @@ qemuCapsComputeCmdFlags(const char *help,
|
||||
* two features. The benefits of JSON mode now outweigh
|
||||
* the downside.
|
||||
*/
|
||||
#if HAVE_YAJL
|
||||
if (version >= 13000)
|
||||
qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
|
||||
#endif
|
||||
|
||||
if (version >= 13000)
|
||||
qemuCapsSet(flags, QEMU_CAPS_PCI_MULTIFUNCTION);
|
||||
|
@ -1545,9 +1545,7 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
|
||||
struct qemud_driver *driver = dom->conn->privateData;
|
||||
virDomainObjPtr vm;
|
||||
int ret = -1;
|
||||
#if HAVE_YAJL
|
||||
qemuDomainObjPrivatePtr priv;
|
||||
#endif
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
@ -1563,7 +1561,6 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#if HAVE_YAJL
|
||||
priv = vm->privateData;
|
||||
|
||||
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON)) {
|
||||
@ -1593,12 +1590,9 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
|
||||
if (qemuDomainObjEndJob(driver, vm) == 0)
|
||||
vm = NULL;
|
||||
} else {
|
||||
#endif
|
||||
qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Reboot is not supported without the JSON monitor"));
|
||||
#if HAVE_YAJL
|
||||
}
|
||||
#endif
|
||||
|
||||
cleanup:
|
||||
if (vm)
|
||||
|
@ -2969,11 +2969,9 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
if (qemuProcessPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
#if HAVE_YAJL
|
||||
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
|
||||
priv->monJSON = 1;
|
||||
else
|
||||
#endif
|
||||
priv->monJSON = 0;
|
||||
|
||||
priv->monError = false;
|
||||
|
@ -56,6 +56,11 @@ static int testHelpStrParsing(const void *data)
|
||||
&version, &is_kvm, &kvm_version) == -1)
|
||||
goto cleanup;
|
||||
|
||||
# ifndef HAVE_YAJL
|
||||
if (qemuCapsGet(info->flags, QEMU_CAPS_MONITOR_JSON))
|
||||
qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
|
||||
# endif
|
||||
|
||||
if (qemuCapsGet(info->flags, QEMU_CAPS_DEVICE)) {
|
||||
VIR_FREE(path);
|
||||
VIR_FREE(help);
|
||||
|
@ -1,5 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
||||
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
pc -m 214 -smp 1 -nographic \
|
||||
-monitor control,unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
|
||||
format=qcow2,cache=off,werror=enospc -drive \
|
||||
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
|
||||
|
@ -1,5 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
||||
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
pc -m 214 -smp 1 -nographic \
|
||||
-monitor control,unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
|
||||
format=qcow2,cache=off,werror=stop,rerror=stop -drive \
|
||||
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
|
||||
|
@ -1,5 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
||||
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
pc -m 214 -smp 1 -nographic \
|
||||
-monitor control,unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
|
||||
format=qcow2,cache=off,werror=report,rerror=ignore -drive \
|
||||
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
|
||||
|
@ -174,7 +174,6 @@ struct testInfo {
|
||||
virBitmapPtr extraFlags;
|
||||
const char *migrateFrom;
|
||||
int migrateFd;
|
||||
bool json;
|
||||
bool expectError;
|
||||
};
|
||||
|
||||
@ -194,7 +193,9 @@ testCompareXMLToArgvHelper(const void *data)
|
||||
|
||||
result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
|
||||
info->migrateFrom, info->migrateFd,
|
||||
info->json, info->expectError);
|
||||
qemuCapsGet(info->extraFlags,
|
||||
QEMU_CAPS_MONITOR_JSON),
|
||||
info->expectError);
|
||||
|
||||
cleanup:
|
||||
free(xml);
|
||||
@ -209,7 +210,6 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *map = NULL;
|
||||
bool json = false;
|
||||
|
||||
abs_top_srcdir = getenv("abs_top_srcdir");
|
||||
if (!abs_top_srcdir)
|
||||
@ -237,7 +237,7 @@ mymain(void)
|
||||
# define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...) \
|
||||
do { \
|
||||
struct testInfo info = { \
|
||||
name, NULL, migrateFrom, migrateFd, json, expectError \
|
||||
name, NULL, migrateFrom, migrateFd, expectError \
|
||||
}; \
|
||||
if (!(info.extraFlags = qemuCapsNew())) \
|
||||
return EXIT_FAILURE; \
|
||||
@ -588,13 +588,11 @@ mymain(void)
|
||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
|
||||
QEMU_CAPS_PCI_MULTIFUNCTION);
|
||||
|
||||
json = true;
|
||||
DO_TEST("monitor-json", false, QEMU_CAPS_DEVICE,
|
||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("no-shutdown", false, QEMU_CAPS_DEVICE,
|
||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG,
|
||||
QEMU_CAPS_NO_SHUTDOWN);
|
||||
json = false;
|
||||
|
||||
free(driver.stateDir);
|
||||
virCapabilitiesFree(driver.caps);
|
||||
|
Loading…
x
Reference in New Issue
Block a user