[libvirt] [PATCH v2 1/3] qemu: XMLToNative: Don't show -S

-S causes qemu to start in the paused state. Since XML2Native is intended to generate something that users can run directly, this will trip them up. --- v2: s/forXMLToArgv/standalone/g src/qemu/qemu_command.c | 8 ++++++-- src/qemu/qemu_command.h | 3 ++- src/qemu/qemu_driver.c | 6 ++++-- src/qemu/qemu_process.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxmlnstest.c | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index aa1a3db..3e6a172 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7711,7 +7711,8 @@ qemuBuildCommandLine(virConnectPtr conn, int migrateFd, virDomainSnapshotObjPtr snapshot, enum virNetDevVPortProfileOp vmop, - qemuBuildCommandLineCallbacksPtr callbacks) + qemuBuildCommandLineCallbacksPtr callbacks, + bool standalone) { virErrorPtr originalError = NULL; size_t i, j; @@ -7820,7 +7821,10 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, def->name); } } - virCommandAddArg(cmd, "-S"); /* freeze CPU */ + + if (!standalone) + virCommandAddArg(cmd, "-S"); /* freeze CPU */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_FIPS)) virCommandAddArg(cmd, "-enable-fips"); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index ebb0b1d..50dc4a0 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -76,7 +76,8 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn, int migrateFd, virDomainSnapshotObjPtr current_snapshot, enum virNetDevVPortProfileOp vmop, - qemuBuildCommandLineCallbacksPtr callbacks) + qemuBuildCommandLineCallbacksPtr callbacks, + bool forXMLToArgv) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(11); /* Generate '-device' string for chardev device */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ba470a1..a01739c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5956,8 +5956,10 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, if (!(cmd = qemuBuildCommandLine(conn, driver, def, &monConfig, monitor_json, qemuCaps, - NULL, -1, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, - &buildCommandLineCallbacks))) + NULL, -1, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, + &buildCommandLineCallbacks, + true))) goto cleanup; ret = virCommandToString(cmd); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 809ab37..35ad62a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3856,7 +3856,7 @@ int qemuProcessStart(virConnectPtr conn, if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig, priv->monJSON, priv->qemuCaps, migrateFrom, stdin_fd, snapshot, vmop, - &buildCommandLineCallbacks))) + &buildCommandLineCallbacks, false))) goto cleanup; /* now that we know it is about to start call the hook if present */ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5d6a64b..8d7d9e5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -357,7 +357,7 @@ static int testCompareXMLToArgvFiles(const char *xml, (flags & FLAG_JSON), extraFlags, migrateFrom, migrateFd, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, - &testCallbacks))) { + &testCallbacks, false))) { if (!virtTestOOMActive() && (flags & FLAG_EXPECT_FAILURE)) { ret = 0; diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 20a5ccd..81d496e 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -119,7 +119,7 @@ static int testCompareXMLToArgvFiles(const char *xml, vmdef, &monitor_chr, json, extraFlags, migrateFrom, migrateFd, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, - &testCallbacks))) + &testCallbacks, false))) goto fail; if (!virtTestOOMActive()) { -- 1.8.5.3

Just skip the vhost command line generation, since this won't work if attempting to run manually. --- v2: s/forXMLToArgv/standalone/g src/qemu/qemu_command.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3e6a172..778d051 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7521,7 +7521,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps, int vlan, int bootindex, - enum virNetDevVPortProfileOp vmop) + enum virNetDevVPortProfileOp vmop, + bool standalone) { int ret = -1; char *nic = NULL, *host = NULL; @@ -7579,10 +7580,11 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, goto cleanup; } - if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK || - actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || - actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || - actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { + if ((actualType == VIR_DOMAIN_NET_TYPE_NETWORK || + actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || + actualType == VIR_DOMAIN_NET_TYPE_DIRECT) && + !standalone) { /* Attempt to use vhost-net mode for these types of network device */ vhostfdSize = net->driver.virtio.queues; @@ -8759,7 +8761,8 @@ qemuBuildCommandLine(virConnectPtr conn, vlan = i; if (qemuBuildInterfaceCommandLine(cmd, driver, conn, def, net, - qemuCaps, vlan, bootNet, vmop) < 0) + qemuCaps, vlan, bootNet, vmop, + standalone) < 0) goto error; last_good_net = i; bootNet = 0; -- 1.8.5.3

Right now we are parsing the XML as though it's live, which for example will choke on hardcoded XML like: <seclabel type='dynamic' model='selinux' relabel='yes'/> Erroring with: $ sudo virsh domxml-to-native qemu-argv f error: XML error: security label is missing All drivers are fixed, but only qemu was tested. --- v2: Fix all drivers src/esx/esx_driver.c | 3 ++- src/libxl/libxl_driver.c | 3 ++- src/qemu/qemu_driver.c | 3 ++- src/xen/xen_driver.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 886d984..6a2efe3 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2836,7 +2836,8 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, } def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, 0); + 1 << VIR_DOMAIN_VIRT_VMWARE, + VIR_DOMAIN_XML_INACTIVE); if (!def) { return NULL; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ae7342a..09ae075 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2979,7 +2979,8 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, if (!(def = virDomainDefParseString(domainXml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, 0))) + 1 << VIR_DOMAIN_VIRT_XEN, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major))) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a01739c..89f443f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5812,7 +5812,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; def = virDomainDefParseString(xmlData, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, 0); + QEMU_EXPECTED_VIRT_TYPES, + VIR_DOMAIN_XML_INACTIVE); if (!def) goto cleanup; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 1880b22..9204f88 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1657,7 +1657,8 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn, } if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, 0))) + 1 << VIR_DOMAIN_VIRT_XEN, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (STREQ(format, XEN_CONFIG_FORMAT_XM)) { -- 1.8.5.3

On 03/14/2014 07:41 AM, Cole Robinson wrote:
-S causes qemu to start in the paused state. Since XML2Native is intended to generate something that users can run directly, this will trip them up. ---
Based on Daniel's answer to my query about the intent of XMLtoNative, ACK on the entire series (what happened to 0/3?)

On 03/14/2014 03:48 PM, Laine Stump wrote:
On 03/14/2014 07:41 AM, Cole Robinson wrote:
-S causes qemu to start in the paused state. Since XML2Native is intended to generate something that users can run directly, this will trip them up. ---
Based on Daniel's answer to my query about the intent of XMLtoNative, ACK on the entire series (what happened to 0/3?)
I just didn't add a cover letter since I assumed the series was straight forward. I'll add one unconditionally in the future. Thanks for the ACKs, pushed now. - Cole
participants (2)
-
Cole Robinson
-
Laine Stump