mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: Introduce qemuBuildFSDevCommandLine
Add new function to manage adding the -fsdev options to the command line removing that task from the mainline qemuBuildCommandLine. Alter the code slightly to perform the !caps and fsdev failure check up front. Since both qemuBuildFSStr and qemuBuildFSDevStr are local, make them static and fix their prototypes to use the const virDomainDef as well. Make some minor formatting changes for long lines. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
0ea0f6c496
commit
3dbc2a149f
@ -1982,8 +1982,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
|
||||
|
||||
char *qemuBuildFSStr(virDomainFSDefPtr fs,
|
||||
virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED)
|
||||
static char *
|
||||
qemuBuildFSStr(virDomainFSDefPtr fs,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
|
||||
@ -2056,8 +2057,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
qemuBuildFSDevStr(virDomainDefPtr def,
|
||||
static char *
|
||||
qemuBuildFSDevStr(const virDomainDef *def,
|
||||
virDomainFSDefPtr fs,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
@ -2075,7 +2076,8 @@ qemuBuildFSDevStr(virDomainDefPtr def,
|
||||
virBufferAddLit(&opt, "virtio-9p-pci");
|
||||
|
||||
virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
|
||||
virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
|
||||
virBufferAsprintf(&opt, ",fsdev=%s%s",
|
||||
QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
|
||||
virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
|
||||
@ -2092,6 +2094,40 @@ qemuBuildFSDevStr(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildFSDevCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV) && def->nfss) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("filesystem passthrough not supported by this QEMU"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < def->nfss; i++) {
|
||||
char *optstr;
|
||||
virDomainFSDefPtr fs = def->fss[i];
|
||||
|
||||
virCommandAddArg(cmd, "-fsdev");
|
||||
if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuControllerModelUSBToCaps(int model)
|
||||
{
|
||||
@ -8013,30 +8049,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
emitBootindex) < 0)
|
||||
goto error;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV)) {
|
||||
for (i = 0; i < def->nfss; i++) {
|
||||
char *optstr;
|
||||
virDomainFSDefPtr fs = def->fss[i];
|
||||
|
||||
virCommandAddArg(cmd, "-fsdev");
|
||||
if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
|
||||
goto error;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
|
||||
goto error;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
}
|
||||
} else {
|
||||
if (def->nfss) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("filesystem passthrough not supported by this QEMU"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
|
||||
goto error;
|
||||
|
||||
if (!def->nnets) {
|
||||
/* If we have -device, then we set -nodefault already */
|
||||
|
@ -117,17 +117,13 @@ char *qemuBuildDriveStr(virConnectPtr conn,
|
||||
virDomainDiskDefPtr disk,
|
||||
bool bootable,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
char *qemuBuildFSStr(virDomainFSDefPtr fs,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
/* Current, best practice */
|
||||
char *qemuBuildDriveDevStr(const virDomainDef *def,
|
||||
virDomainDiskDefPtr disk,
|
||||
int bootindex,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
char *qemuBuildFSDevStr(virDomainDefPtr domainDef,
|
||||
virDomainFSDefPtr fs,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
/* Current, best practice */
|
||||
char *qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
virDomainControllerDefPtr def,
|
||||
|
Loading…
x
Reference in New Issue
Block a user