[PATCH v2] qemu: Move qemuExtDevicesStop() before removing the pidfiles
by Masayoshi Mizuma
From: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
A qemu guest which has virtiofs config fails to start if the previous
starting failed because of invalid option or something.
That's because the virtiofsd isn't killed by virPidFileForceCleanupPath()
on the former failure because the pidfile was already removed by
virFileDeleteTree(priv->libDir) in qemuProcessStop(), so
virPidFileForceCleanupPath() just returned.
Move qemuExtDevicesStop() before virFileDeleteTree(priv->libDir) so that
virPidFileForceCleanupPath() can kill virtiofsd correctly.
For example of the reproduction:
# virsh start guest
error: Failed to start domain guest
error: internal error: process exited while connecting to monitor: qemu-system-x86_64: -foo: invalid option
... fix the option ...
# virsh start guest
error: Failed to start domain guest
error: Cannot open log file: '/var/log/libvirt/qemu/guest-fs0-virtiofsd.log': Device or resource busy
#
Signed-off-by: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
---
src/qemu/qemu_process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0a36b49c85..1963de9fb8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7638,6 +7638,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
/* Do this before we delete the tree and remove pidfile. */
qemuProcessKillManagedPRDaemon(vm);
+ qemuExtDevicesStop(driver, vm);
+
virFileDeleteTree(priv->libDir);
virFileDeleteTree(priv->channelTargetDir);
@@ -7654,8 +7656,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
qemuDomainCleanupRun(driver, vm);
- qemuExtDevicesStop(driver, vm);
-
qemuDBusStop(driver, vm);
vm->def->id = -1;
--
2.27.0
4 years
[PATCH v7 0/4] qemu: Support rbd namespace in rbd source name
by Han Han
Diff from v6: rebase to 6.9.0
v6: https://www.redhat.com/archives/libvir-list/2020-October/msg00707.html
gitlab repo: https://gitlab.com/hhan2/libvirt/-/commits/rbd-namespace-v7
Han Han (4):
qemu_capabilities: Add QEMU_CAPS_RBD_NAMESPACE
util: Add member ns to the storage source struct
conf: Support to parse rbd namespace from source name
qemu: Implement rbd namespace to the source name attribute
docs/formatdomain.rst | 16 ++++++
src/conf/domain_conf.c | 47 ++++++++++++++++--
src/qemu/qemu_block.c | 1 +
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 3 ++
src/qemu/qemu_domain.c | 8 +++
src/util/virstoragefile.c | 2 +
src/util/virstoragefile.h | 1 +
.../caps_5.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 +
.../caps_5.0.0.riscv64.xml | 1 +
.../caps_5.0.0.x86_64.xml | 1 +
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.x86_64.xml | 1 +
...k-network-rbd-namespace.x86_64-latest.args | 49 +++++++++++++++++++
.../disk-network-rbd-namespace.xml | 40 +++++++++++++++
tests/qemuxml2argvtest.c | 1 +
...sk-network-rbd-namespace.x86_64-latest.xml | 49 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
19 files changed, 224 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml
--
2.28.0
4 years
[PATCH v2 0/2] Support mdev_types on CSS devices
by Boris Fiuczynski
All refactoring patches of this series in v1 were accepted except for
actual patch enabling the mdev_types support on CSS devices.
v2 adds one more refactoring patch in docs before the already
sent enablement patch follows again.
Boris Fiuczynski (2):
docs: refactor mdev_types into new paragraph
node_device: detecting mdev_types capability on CSS devices
docs/drvnodedev.html.in | 5 +-
docs/formatnode.html.in | 85 +++++++++++------
docs/schemas/nodedev.rng | 4 +
src/conf/node_device_conf.c | 92 ++++++++++++++++++-
src/conf/node_device_conf.h | 11 +++
src/conf/virnodedeviceobj.c | 7 +-
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 3 +
.../css_0_0_fffe_mdev_types.xml | 17 ++++
tests/nodedevxml2xmltest.c | 1 +
10 files changed, 192 insertions(+), 34 deletions(-)
create mode 100644 tests/nodedevschemadata/css_0_0_fffe_mdev_types.xml
--
2.26.2
4 years
[PATCH 1/8] Added a few attach-disk parameters
by Ryan Gahagan
Signed-off-by: Ryan Gahagan <rgahagan(a)cs.utexas.edu>
---
tools/virsh-domain.c | 76 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 68 insertions(+), 8 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 12b35c037d..16227085cc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -224,6 +224,26 @@ static const vshCmdOptDef opts_attach_disk[] = {
.flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK,
.help = N_("source of disk device")
},
+ {.name = "source-protocol",
+ .type = VSH_OT_STRING,
+ .help = N_("protocol used by disk device source")
+ }
+ {.name = "source-name",
+ .type = VSH_OT_STRING,
+ .help = N_("name of disk device source")
+ },
+ {.name = "source-host-name",
+ .type = VSH_OT_STRING,
+ .help = N_("host name for source of disk device")
+ },
+ {.name = "source-host-transport",
+ .type = VSH_OT_STRING,
+ .help = N_("host transport for source of disk device")
+ },
+ {.name = "source-host-socket",
+ .type = VSH_OT_STRING,
+ .help = N_("host socket for source of disk device")
+ },
{.name = "target",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -562,11 +582,13 @@ static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- const char *source = NULL, *target = NULL, *driver = NULL,
- *subdriver = NULL, *type = NULL, *mode = NULL,
- *iothread = NULL, *cache = NULL, *io = NULL,
- *serial = NULL, *straddr = NULL, *wwn = NULL,
- *targetbus = NULL, *alias = NULL;
+ const char *source = NULL, *source_name = NULL, *source_protocol = NULL,
+ *target = NULL, *driver = NULL, *subdriver = NULL, *type = NULL,
+ *mode = NULL, *iothread = NULL, *cache = NULL,
+ *io = NULL, *serial = NULL, *straddr = NULL,
+ *wwn = NULL, *targetbus = NULL, *alias = NULL,
+ *host_name = NULL, *host_transport = NULL,
+ *host_port = NULL, *host_socket = NULL;
struct DiskAddress diskAddr;
bool isFile = false, functionReturn = false;
int ret;
@@ -591,6 +613,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-name", &source_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-protocol", &source_protocol) < 0 ||
vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||
vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 ||
@@ -604,7 +628,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 ||
vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0)
+ vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-name", &host_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-transport", &host_transport) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-socket", &host_socket) < 0)
goto cleanup;
if (!stype) {
@@ -659,9 +686,42 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAddLit(&buf, "/>\n");
}
- if (source)
- virBufferAsprintf(&buf, "<source %s='%s'/>\n",
+ if (source || source_protocol || source_name ||
+ host_name || host_transport || host_socket) {
+ virBufferAsprintf(&buf, "<source");
+
+ if (source)
+ virBufferAsprintf(&buf, " %s='%s'",
isFile ? "file" : "dev", source);
+ if (source_protocol)
+ virBufferAsprintf(&buf, " protocol='%s'", source_protocol);
+ if (source_name)
+ virBufferAsprintf(&buf, " name='%s'", source_name);
+
+ if (host_name || host_transport || host_socket) {
+ virBufferAsprintf(">\n<host");
+
+ if (host_name) {
+ host_port = strchr(host_name, ':');
+
+ if (!host_port)
+ virBufferAsprintf(" name='%s'", host_name);
+ else {
+ host_name[host_port - host_name] = '\0';
+ virBufferAsprintf(" name='%s' port='%s'", host_name, host_port + 1);
+ }
+ }
+ if (host_transport)
+ virBufferAsprintf(" transport='%s'", host_transport);
+ if (host_socket)
+ virBufferAsprintf(" socket='%s'", host_socket);
+
+ virBufferAsprintf(" />\n</source>\n");
+ } else {
+ virBufferAsprintf(" />\n");
+ }
+ }
+
virBufferAsprintf(&buf, "<target dev='%s'", target);
if (targetbus)
virBufferAsprintf(&buf, " bus='%s'", targetbus);
--
2.29.0
4 years
[libvirt] [PATCH v2 00/13] virsh completion improvement
by Lin Ma
Add more bash completions for some of virsh subcommands/subparameters.
v1->v2
* Follow Michal's suggestions:
- guestvcpus command: complete offlined vCPUs if --enable, complete onlined vCPUs if --disable
- Added a static helper function for interface string provider,
- Adjusted some needlessly complicated loops.
* Refered to Peter and Michal's comments, I droped the vnc completion patches.
* Concentrate on completion itself, Drop all of patches which related to macros to make review easier.
Lin Ma (13):
virsh: Add vcpu list completion to guestvcpus command
virsh: Add logical CPU IDs completion for nodecpustats command
virsh: Add serial/parallel device name completion to console command
virsh-interface: Add a static helper virshInterfaceStringHelper
virsh: Add interface mac completion to iface-name command
virsh: Add interface name completion to iface-bridge command
virsh: Add interface name completion to iface-mac command
vsh: Fix completion error in case of multiple mac addresses
virsh: Add mac completion to net-dhcp-leases command
virsh: Move/add some of function declarations to virsh-domain.h
virsh: Add signal name completion to send-process-signal command
virsh: Add lifecycle type completion to set-lifecycle-action command
Add lifecycle action completion to set-lifecycle-action command
tools/bash-completion/vsh | 1 +
tools/virsh-completer-domain.c | 190 ++++++++++++++++++++++++++++++
tools/virsh-completer-domain.h | 20 ++++
tools/virsh-completer-host.c | 31 +++++
tools/virsh-completer-host.h | 4 +
tools/virsh-completer-interface.c | 34 ++++--
tools/virsh-completer-interface.h | 7 ++
tools/virsh-completer-network.c | 44 +++++++
tools/virsh-completer-network.h | 4 +
tools/virsh-domain.c | 6 +-
tools/virsh-domain.h | 4 +
tools/virsh-host.c | 1 +
tools/virsh-interface.c | 3 +
tools/virsh-network.c | 15 ++-
14 files changed, 349 insertions(+), 15 deletions(-)
--
2.26.0
4 years
[libvirt PATCH] qemu: add qemuAgentSSH{Add,Remove,Get}AuthorizedKeys
by marcandre.lureau@redhat.com
From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
In QEMU 5.2, the guest agent learned to manipulate a user
~/.ssh/authorized_keys. Bind the JSON API to libvirt.
https://wiki.qemu.org/ChangeLog/5.2#Guest_agent
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1888537
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/qemu/qemu_agent.c | 158 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 26 +++++++
tests/qemuagenttest.c | 80 +++++++++++++++++++++
3 files changed, 264 insertions(+)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 7fbb4a9431..75e7fea9e4 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2496,3 +2496,161 @@ qemuAgentSetResponseTimeout(qemuAgentPtr agent,
{
agent->timeout = timeout;
}
+
+void qemuAgentSSHAuthorizedKeyFree(qemuAgentSSHAuthorizedKeyPtr key)
+{
+ if (!key)
+ return;
+
+ g_free(key->key);
+ g_free(key);
+}
+
+/* Returns: 0 on success
+ * -2 when agent command is not supported by the agent and
+ * 'report_unsupported' is false (libvirt error is not reported)
+ * -1 otherwise (libvirt error is reported)
+ */
+int qemuAgentSSHGetAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr **keys,
+ bool report_unsupported)
+{
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ virJSONValuePtr data = NULL;
+ size_t ndata;
+ size_t i;
+ int rc;
+ qemuAgentSSHAuthorizedKeyPtr *keys_ret = NULL;
+
+ if (!(cmd = qemuAgentMakeCommand("guest-ssh-get-authorized-keys",
+ "s:username", user,
+ NULL)))
+ return -1;
+
+ if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
+ report_unsupported)) < 0)
+ return rc;
+
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("qemu agent didn't return an array of keys"));
+ return -1;
+ }
+ ndata = virJSONValueArraySize(data);
+
+ keys_ret = g_new0(qemuAgentSSHAuthorizedKeyPtr, ndata);
+
+ for (i = 0; i < ndata; i++) {
+ virJSONValuePtr entry = virJSONValueArrayGet(data, i);
+
+ if (!entry) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("array element missing in guest-ssh-get-authorized-keys return "
+ "value"));
+ goto cleanup;
+ }
+
+ keys_ret[i] = g_new0(qemuAgentSSHAuthorizedKey, 1);
+ keys_ret[i]->key = g_strdup(virJSONValueGetString(entry));
+ }
+
+ *keys = g_steal_pointer(&keys_ret);
+ return ndata;
+
+ cleanup:
+ if (keys_ret) {
+ for (i = 0; i < ndata; i++)
+ qemuAgentSSHAuthorizedKeyFree(keys_ret[i]);
+ g_free(keys_ret);
+ }
+ return -1;
+}
+
+static virJSONValuePtr
+makeJSONArrayFromKeys(qemuAgentSSHAuthorizedKeyPtr *keys,
+ size_t nkeys)
+{
+ g_autoptr(virJSONValue) jkeys = NULL;
+ size_t i;
+
+ jkeys = virJSONValueNewArray();
+
+ for (i = 0; i < nkeys; i++) {
+ qemuAgentSSHAuthorizedKeyPtr k = keys[i];
+
+ if (virJSONValueArrayAppendString(jkeys, k->key) < 0)
+ return NULL;
+ }
+
+ return g_steal_pointer(&jkeys);
+}
+
+/* Returns: 0 on success
+ * -2 when agent command is not supported by the agent and
+ * 'report_unsupported' is false (libvirt error is not reported)
+ * -1 otherwise (libvirt error is reported)
+ */
+int qemuAgentSSHAddAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr *keys,
+ size_t nkeys,
+ bool reset,
+ bool report_unsupported)
+{
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ g_autoptr(virJSONValue) jkeys = NULL;
+ int rc;
+
+ jkeys = makeJSONArrayFromKeys(keys, nkeys);
+ if (jkeys == NULL)
+ return -1;
+
+ if (!(cmd = qemuAgentMakeCommand("guest-ssh-add-authorized-keys",
+ "s:username", user,
+ "a:keys", &jkeys,
+ "b:reset", reset,
+ NULL)))
+ return -1;
+
+ if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
+ report_unsupported)) < 0)
+ return rc;
+
+ return 0;
+}
+
+/* Returns: 0 on success
+ * -2 when agent command is not supported by the agent and
+ * 'report_unsupported' is false (libvirt error is not reported)
+ * -1 otherwise (libvirt error is reported)
+ */
+int qemuAgentSSHRemoveAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr *keys,
+ size_t nkeys,
+ bool report_unsupported)
+{
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ g_autoptr(virJSONValue) jkeys = NULL;
+ int rc;
+
+ jkeys = makeJSONArrayFromKeys(keys, nkeys);
+ if (jkeys == NULL)
+ return -1;
+
+ if (!(cmd = qemuAgentMakeCommand("guest-ssh-remove-authorized-keys",
+ "s:username", user,
+ "a:keys", &jkeys,
+ NULL)))
+ return -1;
+
+ if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
+ report_unsupported)) < 0)
+ return rc;
+
+ return 0;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 2eeb376a68..3e70a55c19 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -67,6 +67,12 @@ typedef enum {
QEMU_AGENT_SHUTDOWN_LAST,
} qemuAgentShutdownMode;
+typedef struct _qemuAgentSSHAuthorizedKey qemuAgentSSHAuthorizedKey;
+typedef qemuAgentSSHAuthorizedKey *qemuAgentSSHAuthorizedKeyPtr;
+struct _qemuAgentSSHAuthorizedKey {
+ char *key;
+};
+
typedef struct _qemuAgentDiskInfo qemuAgentDiskInfo;
typedef qemuAgentDiskInfo *qemuAgentDiskInfoPtr;
struct _qemuAgentDiskInfo {
@@ -170,3 +176,23 @@ int qemuAgentGetTimezone(qemuAgentPtr mon,
void qemuAgentSetResponseTimeout(qemuAgentPtr mon,
int timeout);
+
+void qemuAgentSSHAuthorizedKeyFree(qemuAgentSSHAuthorizedKeyPtr key);
+
+int qemuAgentSSHGetAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr **keys,
+ bool report_unsupported);
+
+int qemuAgentSSHAddAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr *keys,
+ size_t nkeys,
+ bool reset,
+ bool report_unsupported);
+
+int qemuAgentSSHRemoveAuthorizedKeys(qemuAgentPtr agent,
+ const char *user,
+ qemuAgentSSHAuthorizedKeyPtr *keys,
+ size_t nkeys,
+ bool report_unsupported);
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 607bd97b5c..eda688850f 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -35,6 +35,85 @@
virQEMUDriver driver;
+static int
+testQemuAgentSSHKeys(const void *data)
+{
+ virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+ qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
+ qemuAgentSSHAuthorizedKeyPtr *keys = NULL;
+ int nkeys = 0, i;
+ int ret = -1;
+
+ if (!test)
+ return -1;
+
+ if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+ goto cleanup;
+
+ if (qemuMonitorTestAddItem(test, "guest-ssh-get-authorized-keys",
+ "{ \"return\" : [\"algo1 key1 comments1\","
+ " \"algo2 key2 comments2\"] }") < 0)
+ goto cleanup;
+
+ if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+ goto cleanup;
+
+ if (qemuMonitorTestAddItem(test, "guest-ssh-add-authorized-keys",
+ "{ \"return\" : {} }") < 0)
+ goto cleanup;
+
+ if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+ goto cleanup;
+
+ if (qemuMonitorTestAddItem(test, "guest-ssh-remove-authorized-keys",
+ "{ \"return\" : {} }") < 0)
+ goto cleanup;
+
+ if ((nkeys = qemuAgentSSHGetAuthorizedKeys(qemuMonitorTestGetAgent(test),
+ "user",
+ &keys,
+ true)) < 0)
+ goto cleanup;
+
+ if (nkeys != 2) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "expected 2 keys, got %d", nkeys);
+ ret = -1;
+ goto cleanup;
+ }
+
+ if (STRNEQ(keys[1]->key, "algo2 key2 comments2")) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected key returned: %s", keys[1]->key);
+ ret = -1;
+ goto cleanup;
+ }
+
+ if ((ret = qemuAgentSSHAddAuthorizedKeys(qemuMonitorTestGetAgent(test),
+ "user",
+ keys,
+ nkeys,
+ true,
+ true)) < 0)
+ goto cleanup;
+
+ if ((ret = qemuAgentSSHRemoveAuthorizedKeys(qemuMonitorTestGetAgent(test),
+ "user",
+ keys,
+ nkeys,
+ true)) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ for (i = 0; i < nkeys; i++)
+ qemuAgentSSHAuthorizedKeyFree(keys[i]);
+ VIR_FREE(keys);
+ qemuMonitorTestFree(test);
+ return ret;
+}
+
+
static int
testQemuAgentFSFreeze(const void *data)
{
@@ -1315,6 +1394,7 @@ mymain(void)
DO_TEST(Users);
DO_TEST(OSInfo);
DO_TEST(Timezone);
+ DO_TEST(SSHKeys);
DO_TEST(Timeout); /* Timeout should always be called last */
--
2.29.0
4 years
[libvirt] [PATCH 00/19] virsh completion improvement
by Lin Ma
Lin Ma (19):
virsh: Add current vcpu list completion to guestvcpus command
virsh: Add logical CPU IDs completion for nodecpustats command
virsh: Add serial/parallel device name completion to console command
virsh: Rename virshInterfaceNameCompleter to virshInterfaceCompleter
virsh: create a macro with a _FULL suffix for common --interface
option
virsh: Add interface name completion to iface-bridge command
virsh: Add interface name completion to iface-mac command
virsh: Add interface mac completion to iface-name command
virdomainobjlist: Add vnc into filter group to check the vnc existence
of guest
virsh: Only return domains that have VNC display to vncdisplay command
vsh: Fix completion error in case of multiple mac addresses
virsh: Add mac completion to net-dhcp-leases command
virsh-domain: Introduce 2 macros for domain options 'interface' and
'mac'
virsh-domain: Apply macro VIRSH_DOMAIN_OPT_INTERFACE for interface
option
virsh-domain: Apply macro VIRSH_DOMAIN_OPT_MAC for mac option
virsh: Move/add some of function declarations to virsh-domain.h
virsh: Add signal name completion to send-process-signal command
virsh: Add lifecycle type completion to set-lifecycle-action command
virsh: Add lifecycle action completion to set-lifecycle-action command
include/libvirt/libvirt-domain.h | 3 +
src/conf/virdomainobjlist.c | 15 +++
src/conf/virdomainobjlist.h | 7 +-
tools/bash-completion/vsh | 1 +
tools/virsh-completer-domain.c | 153 +++++++++++++++++++++++++++++-
tools/virsh-completer-domain.h | 20 ++++
tools/virsh-completer-host.c | 35 +++++++
tools/virsh-completer-host.h | 4 +
tools/virsh-completer-interface.c | 19 ++--
tools/virsh-completer-interface.h | 10 +-
tools/virsh-completer-network.c | 45 +++++++++
tools/virsh-completer-network.h | 4 +
tools/virsh-domain-monitor.c | 20 +---
tools/virsh-domain-monitor.h | 1 +
tools/virsh-domain.c | 30 ++----
tools/virsh-domain.h | 22 +++++
tools/virsh-host.c | 1 +
tools/virsh-interface.c | 39 ++++----
tools/virsh-network.c | 15 ++-
19 files changed, 367 insertions(+), 77 deletions(-)
--
2.26.0
4 years
[PATCH] util: convert char pointers to use g_autofree
by Ryan Gahagan
From: Barrett Schonefeld <bschoney(a)utexas.edu>
additional conversions to the GLib API in src/util per issue #11.
files updated are:
- src/util/vircgroupv1.c
- src/util/virhostcpu.c
- src/util/virlockspace.c
- src/util/virmacmap.c
- src/util/virresctrl.c
- src/util/virsysinfo.c
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/11
Signed-off-by: bschoney <bschoney(a)utexas.edu>
Signed-off-by: Barrett Schonefeld <bschoney(a)utexas.edu>
---
src/util/vircgroupv1.c | 3 +--
src/util/virhostcpu.c | 4 +---
src/util/virlockspace.c | 6 ++----
src/util/virmacmap.c | 3 +--
src/util/virresctrl.c | 25 ++++++++-----------------
src/util/virsysinfo.c | 9 +++------
6 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 731e9d61d4..984cd50409 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1549,7 +1549,7 @@ virCgroupV1GetMemoryStat(virCgroupPtr group,
unsigned long long *unevictable)
{
int ret = -1;
- char *stat = NULL;
+ g_autofree char *stat = NULL;
char *line = NULL;
unsigned long long cacheVal = 0;
unsigned long long activeAnonVal = 0;
@@ -1614,7 +1614,6 @@ virCgroupV1GetMemoryStat(virCgroupPtr group,
ret = 0;
cleanup:
- VIR_FREE(stat);
return ret;
}
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index c531d65f86..4f6c3390ce 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -87,7 +87,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
int *nparams)
{
const char *sysctl_name;
- long *cpu_times;
+ g_autofree long *cpu_times = NULL;
struct clockinfo clkinfo;
size_t i, j, cpu_times_size, clkinfo_size;
int cpu_times_num, offset, hz, stathz, ret = -1;
@@ -172,8 +172,6 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
ret = 0;
cleanup:
- VIR_FREE(cpu_times);
-
return ret;
}
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index b90e13f506..71d5dfb83e 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -515,7 +515,7 @@ int virLockSpaceCreateResource(virLockSpacePtr lockspace,
const char *resname)
{
int ret = -1;
- char *respath = NULL;
+ g_autofree char *respath = NULL;
VIR_DEBUG("lockspace=%p resname=%s", lockspace, resname);
@@ -538,7 +538,6 @@ int virLockSpaceCreateResource(virLockSpacePtr lockspace,
cleanup:
virMutexUnlock(&lockspace->lock);
- VIR_FREE(respath);
return ret;
}
@@ -547,7 +546,7 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspace,
const char *resname)
{
int ret = -1;
- char *respath = NULL;
+ g_autofree char *respath = NULL;
VIR_DEBUG("lockspace=%p resname=%s", lockspace, resname);
@@ -575,7 +574,6 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspace,
cleanup:
virMutexUnlock(&lockspace->lock);
- VIR_FREE(respath);
return ret;
}
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index f9047d0fb1..e68742de10 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -129,7 +129,7 @@ static int
virMacMapLoadFile(virMacMapPtr mgr,
const char *file)
{
- char *map_str = NULL;
+ g_autofree char *map_str = NULL;
virJSONValuePtr map = NULL;
int map_str_len = 0;
size_t i;
@@ -189,7 +189,6 @@ virMacMapLoadFile(virMacMapPtr mgr,
ret = 0;
cleanup:
- VIR_FREE(map_str);
virJSONValueFree(map);
return ret;
}
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index d3087b98c1..1c2d175295 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -709,7 +709,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
{
int ret = -1;
int rv = -1;
- char *featurestr = NULL;
+ g_autofree char *featurestr = NULL;
char **features = NULL;
size_t nfeatures = 0;
virResctrlInfoMongrpPtr info_monitor = NULL;
@@ -771,7 +771,6 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
ret = 0;
cleanup:
- VIR_FREE(featurestr);
g_strfreev(features);
VIR_FREE(info_monitor);
return ret;
@@ -1736,7 +1735,7 @@ virResctrlAllocGetGroup(virResctrlInfoPtr resctrl,
const char *groupname,
virResctrlAllocPtr *alloc)
{
- char *schemata = NULL;
+ g_autofree char *schemata = NULL;
int rv = virFileReadValueString(&schemata,
SYSFS_RESCTRL_PATH "/%s/schemata",
groupname);
@@ -1753,11 +1752,9 @@ virResctrlAllocGetGroup(virResctrlInfoPtr resctrl,
if (virResctrlAllocParse(resctrl, *alloc, schemata) < 0)
goto error;
- VIR_FREE(schemata);
return 0;
error:
- VIR_FREE(schemata);
virObjectUnref(*alloc);
*alloc = NULL;
return -1;
@@ -2354,8 +2351,8 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
virResctrlAllocPtr alloc,
const char *machinename)
{
- char *schemata_path = NULL;
- char *alloc_str = NULL;
+ g_autofree char *schemata_path = NULL;
+ g_autofree char *alloc_str = NULL;
int ret = -1;
int lockfd = -1;
@@ -2403,8 +2400,6 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
ret = 0;
cleanup:
virResctrlUnlock(lockfd);
- VIR_FREE(alloc_str);
- VIR_FREE(schemata_path);
return ret;
}
@@ -2413,8 +2408,8 @@ static int
virResctrlAddPID(const char *path,
pid_t pid)
{
- char *tasks = NULL;
- char *pidstr = NULL;
+ g_autofree char *tasks = NULL;
+ g_autofree char *pidstr = NULL;
int ret = 0;
if (!path) {
@@ -2436,8 +2431,6 @@ virResctrlAddPID(const char *path,
ret = 0;
cleanup:
- VIR_FREE(tasks);
- VIR_FREE(pidstr);
return ret;
}
@@ -2657,8 +2650,8 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
size_t i = 0;
unsigned long long val = 0;
g_autoptr(DIR) dirp = NULL;
- char *datapath = NULL;
- char *filepath = NULL;
+ g_autofree char *datapath = NULL;
+ g_autofree char *filepath = NULL;
struct dirent *ent = NULL;
virResctrlMonitorStatsPtr stat = NULL;
@@ -2737,8 +2730,6 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
ret = 0;
cleanup:
- VIR_FREE(datapath);
- VIR_FREE(filepath);
virResctrlMonitorStatsFree(stat);
return ret;
}
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 217f842a37..e1336bf566 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -532,9 +532,9 @@ static int
virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
{
const char *tmp_base;
- char *manufacturer = NULL;
- char *procline = NULL;
- char *ncpu = NULL;
+ g_autofree char *manufacturer = NULL;
+ g_autofree char *procline = NULL;
+ g_autofree char *ncpu = NULL;
int result = -1;
virSysinfoProcessorDefPtr processor;
@@ -593,9 +593,6 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
result = 0;
error:
- VIR_FREE(manufacturer);
- VIR_FREE(procline);
- VIR_FREE(ncpu);
return result;
}
--
2.29.0
4 years
[libvirt PATCH] virgdbus: fix getting non-shared DBus connection
by Pavel Hrdina
We need to pass some flags in order to properly initialize the
connection otherwise it will not work. This copies what GLib does
for g_bus_get_sync() internally.
This fixes an issue with LXC driver where libvirt was not able to
register any VM with machined.
Reported-by: Matthias Maier <tamiko(a)gentoo.org>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/virgdbus.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/util/virgdbus.c b/src/util/virgdbus.c
index 19fd7e2fe4..4ad1a5c842 100644
--- a/src/util/virgdbus.c
+++ b/src/util/virgdbus.c
@@ -54,11 +54,15 @@ virGDBusBusInit(GBusType type, GError **error)
if (sharedBus) {
return g_bus_get_sync(type, NULL, error);
} else {
+ GDBusConnectionFlags dbusFlags =
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+ G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION;
+
address = g_dbus_address_get_for_bus_sync(type, NULL, error);
if (*error)
return NULL;
return g_dbus_connection_new_for_address_sync(address,
- G_DBUS_CONNECTION_FLAGS_NONE,
+ dbusFlags,
NULL,
NULL,
error);
--
2.26.2
4 years
[PATCH] domain_conf: make virDomainDiskSetSource() void
by Matt Coleman
The function only returns zero or aborts, so it might as well be void.
This has the added benefit of simplifying the code that calls it.
Signed-off-by: Matt Coleman <matt(a)datto.com>
---
src/conf/domain_conf.c | 3 +--
src/conf/domain_conf.h | 3 +--
src/libxl/libxl_driver.c | 6 ++----
src/libxl/xen_xl.c | 3 +--
src/libxl/xen_xm.c | 13 ++++---------
src/lxc/lxc_controller.c | 13 ++-----------
src/vbox/vbox_common.c | 6 +-----
src/vmx/vmx.c | 36 ++++++++++++------------------------
src/vz/vz_sdk.c | 4 ++--
9 files changed, 26 insertions(+), 61 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7696b12ef9..5c8ec19da8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2241,13 +2241,12 @@ virDomainDiskGetSource(virDomainDiskDef const *def)
}
-int
+void
virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
{
char *tmp = g_strdup(src);
g_free(def->src->path);
def->src->path = tmp;
- return 0;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8a487e9de3..c164b28ea1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3040,8 +3040,7 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
-int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
- G_GNUC_WARN_UNUSED_RESULT;
+void virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src);
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 824ed60dfd..00a74dcb49 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3022,8 +3022,7 @@ libxlDomainChangeEjectableMedia(virDomainObjPtr vm, virDomainDiskDefPtr disk)
goto cleanup;
}
- if (virDomainDiskSetSource(origdisk, virDomainDiskGetSource(disk)) < 0)
- goto cleanup;
+ virDomainDiskSetSource(origdisk, virDomainDiskGetSource(disk));
virDomainDiskSetType(origdisk, virDomainDiskGetType(disk));
virDomainDiskDefFree(disk);
@@ -4084,8 +4083,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
return -1;
}
- if (virDomainDiskSetSource(orig, virDomainDiskGetSource(disk)) < 0)
- return -1;
+ virDomainDiskSetSource(orig, virDomainDiskGetSource(disk));
virDomainDiskSetType(orig, virDomainDiskGetType(disk));
virDomainDiskSetFormat(orig, virDomainDiskGetFormat(disk));
if (virDomainDiskSetDriver(orig, virDomainDiskGetDriver(disk)) < 0)
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 74f48e4117..d195f866c5 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -641,8 +641,7 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
ret = virStorageSourceParseRBDColonString(tmpstr, disk->src);
} else {
- if (virDomainDiskSetSource(disk, srcstr) < 0)
- goto cleanup;
+ virDomainDiskSetSource(disk, srcstr);
ret = 0;
}
diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c
index 9063a43135..283ed1ee8b 100644
--- a/src/libxl/xen_xm.c
+++ b/src/libxl/xen_xm.c
@@ -129,14 +129,11 @@ xenParseXMDisk(char *entry, int hvm)
if (offset == head) {
/* No source file given, eg CDROM with no media */
- ignore_value(virDomainDiskSetSource(disk, NULL));
+ virDomainDiskSetSource(disk, NULL);
} else {
tmp = g_strndup(head, offset - head);
- if (virDomainDiskSetSource(disk, tmp) < 0) {
- VIR_FREE(tmp);
- goto error;
- }
+ virDomainDiskSetSource(disk, tmp);
VIR_FREE(tmp);
}
@@ -175,8 +172,7 @@ xenParseXMDisk(char *entry, int hvm)
VIR_FREE(tmp);
/* Strip the prefix we found off the source file name */
- if (virDomainDiskSetSource(disk, src + len + 1) < 0)
- goto error;
+ virDomainDiskSetSource(disk, src + len + 1);
src = virDomainDiskGetSource(disk);
}
@@ -206,8 +202,7 @@ xenParseXMDisk(char *entry, int hvm)
}
/* Strip the prefix we found off the source file name */
- if (virDomainDiskSetSource(disk, src + len + 1) < 0)
- goto error;
+ virDomainDiskSetSource(disk, src + len + 1);
src = virDomainDiskGetSource(disk);
}
}
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 4f77a6ace8..97de0408b6 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -479,7 +479,6 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
int lofd;
g_autofree char *loname = NULL;
const char *src = virDomainDiskGetSource(disk);
- int ret = -1;
if ((lofd = virFileLoopDeviceAssociate(src, &loname)) < 0)
return -1;
@@ -492,14 +491,7 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
* the rest of container setup 'just works'
*/
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
- if (virDomainDiskSetSource(disk, loname) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- if (ret < 0)
- VIR_FORCE_CLOSE(lofd);
+ virDomainDiskSetSource(disk, loname);
return lofd;
@@ -561,8 +553,7 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
* the rest of container setup 'just works'
*/
virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
- if (virDomainDiskSetSource(disk, dev) < 0)
- return -1;
+ virDomainDiskSetSource(disk, dev);
return 0;
}
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index d072ca8015..26168c3c5b 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3309,11 +3309,7 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8);
- if (virDomainDiskSetSource(disk, mediumLocUtf8) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Could not set disk source"));
- goto cleanup;
- }
+ virDomainDiskSetSource(disk, mediumLocUtf8);
rc = gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly);
if (NS_FAILED(rc)) {
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 5fac290a5e..4001174380 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2410,10 +2410,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
goto cleanup;
- if (virDomainDiskSetSource(*def, tmp) < 0) {
- VIR_FREE(tmp);
- goto cleanup;
- }
+ virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
(*def)->cachemode = writeThrough ? VIR_DOMAIN_DISK_CACHE_WRITETHRU
: VIR_DOMAIN_DISK_CACHE_DEFAULT;
@@ -2450,19 +2447,16 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
goto cleanup;
- if (virDomainDiskSetSource(*def, tmp) < 0) {
- VIR_FREE(tmp);
- goto cleanup;
- }
+ virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
if (fileName && STRCASEEQ(fileName, "auto detect")) {
- ignore_value(virDomainDiskSetSource(*def, NULL));
+ virDomainDiskSetSource(*def, NULL);
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
- } else if (virDomainDiskSetSource(*def, fileName) < 0) {
- goto cleanup;
+ } else {
+ virDomainDiskSetSource(*def, fileName);
}
} else if (deviceType && STRCASEEQ(deviceType, "cdrom-raw")) {
/* Raw access CD-ROMs actually are device='lun' */
@@ -2470,10 +2464,10 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
if (fileName && STRCASEEQ(fileName, "auto detect")) {
- ignore_value(virDomainDiskSetSource(*def, NULL));
+ virDomainDiskSetSource(*def, NULL);
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
- } else if (virDomainDiskSetSource(*def, fileName) < 0) {
- goto cleanup;
+ } else {
+ virDomainDiskSetSource(*def, fileName);
}
} else if (busType == VIR_DOMAIN_DISK_BUS_SCSI &&
deviceType && STRCASEEQ(deviceType, "scsi-passthru")) {
@@ -2481,9 +2475,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
/* SCSI-passthru CD-ROMs actually are device='lun' */
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
-
- if (virDomainDiskSetSource(*def, fileName) < 0)
- goto cleanup;
+ virDomainDiskSetSource(*def, fileName);
} else {
/*
* This function was called in order to parse a CDROM device,
@@ -2502,7 +2494,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
}
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
- ignore_value(virDomainDiskSetSource(*def, NULL));
+ virDomainDiskSetSource(*def, NULL);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' "
@@ -2514,18 +2506,14 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
} else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
if (fileType != NULL && STRCASEEQ(fileType, "device")) {
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
- if (virDomainDiskSetSource(*def, fileName) < 0)
- goto cleanup;
+ virDomainDiskSetSource(*def, fileName);
} else if (fileType != NULL && STRCASEEQ(fileType, "file")) {
char *tmp = NULL;
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
if (fileName && !(tmp = ctx->parseFileName(fileName, ctx->opaque)))
goto cleanup;
- if (virDomainDiskSetSource(*def, tmp) < 0) {
- VIR_FREE(tmp);
- goto cleanup;
- }
+ virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 7877974628..6a0ab5c862 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -674,8 +674,8 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
if (!(buf = prlsdkGetStringParamVar(PrlVmDev_GetFriendlyName, prldisk)))
goto cleanup;
- if (*buf != '\0' && virDomainDiskSetSource(disk, buf) < 0)
- goto cleanup;
+ if (*buf != '\0')
+ virDomainDiskSetSource(disk, buf);
if (prlsdkGetDiskId(prldisk, &disk->bus, &disk->dst) < 0)
goto cleanup;
--
2.27.0
4 years