error:
virBufferFreeAndReset(&buf);
- return -1;
+ return NULL;
+}
+
+char *
+qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem,
+ virQEMUCapsPtr qemuCaps)
+{
+ char *devstr = NULL;
+ virDomainChrSourceDef source = {
+ .type = VIR_DOMAIN_CHR_TYPE_UNIX,
+ .data.nix = {
+ .path = shmem->server.path,
+ .listen = false,
+ }
+ };
+
+ if (!shmem->server.path &&
+ virAsprintf(&source.data.nix.path,
+ "/var/lib/libvirt/shmem-%s-sock",
+ shmem->name) < 0)
+ return NULL;
+
+ devstr = qemuBuildChrChardevStr(&source, shmem->info.alias,
qemuCaps);
+
+ if (!shmem->server.path)
+ VIR_FREE(source.data.nix.path);
+
+ return devstr;
}
static int
@@ -8505,35 +8528,18 @@ qemuBuildShmemCommandLine(virCommandPtr cmd,
virDomainShmemDefPtr shmem,
virQEMUCapsPtr qemuCaps)
{
- if (qemuBuildShmemDevCmd(cmd, def, shmem, qemuCaps) < 0)
+ char *devstr = NULL;
+
+ if (!(devstr = qemuBuildShmemDevStr(def, shmem, qemuCaps)))
return -1;
+ virCommandAddArgList(cmd, "-device", devstr, NULL);
+ VIR_FREE(devstr);
if (shmem->server.enabled) {
- char *devstr = NULL;
- virDomainChrSourceDef source = {
- .type = VIR_DOMAIN_CHR_TYPE_UNIX,
- .data.nix = {
- .path = shmem->server.path,
- .listen = false,
- }
- };
-
- if (!shmem->server.path &&
- virAsprintf(&source.data.nix.path,
- "/var/lib/libvirt/shmem-%s-sock",
- shmem->name) < 0)
+ if (!(devstr = qemuBuildShmemBackendStr(shmem, qemuCaps)))
return -1;
- devstr = qemuBuildChrChardevStr(&source, shmem->info.alias,
qemuCaps);
-
- if (!shmem->server.path)
- VIR_FREE(source.data.nix.path);
-
- if (!devstr)
- return -1;
-
- virCommandAddArg(cmd, "-chardev");
- virCommandAddArg(cmd, devstr);
+ virCommandAddArgList(cmd, "-chardev", devstr, NULL);
VIR_FREE(devstr);
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 0fc59a8..73f24dc 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -194,6 +194,13 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr
rng,
const char **type,
virJSONValuePtr *props);
+char *qemuBuildShmemDevStr(virDomainDefPtr def,
+ virDomainShmemDefPtr shmem,
+ virQEMUCapsPtr qemuCaps);
+char *qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem,
+ virQEMUCapsPtr qemuCaps);
+
+
int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);
/* Legacy, pre device support */
--
1.8.3.1
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list