1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

qemu: always assume QEMU_CAPS_DRIVE_READONLY

We have been always setting the capability on if qemu has
QEMU_CAPS_DEVICE.
This commit is contained in:
Ján Tomko 2016-05-20 13:29:54 +02:00
parent ec9d19952a
commit 00c9877e77
4 changed files with 14 additions and 37 deletions

View File

@ -4079,8 +4079,7 @@ virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
static int static int
virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps, virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader,
virDomainCapsLoaderPtr capsLoader,
char **loader, char **loader,
size_t nloader) size_t nloader)
{ {
@ -4112,25 +4111,22 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
VIR_DOMAIN_LOADER_TYPE_PFLASH); VIR_DOMAIN_LOADER_TYPE_PFLASH);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly, VIR_TRISTATE_BOOL_YES,
VIR_TRISTATE_BOOL_YES, VIR_TRISTATE_BOOL_NO);
VIR_TRISTATE_BOOL_NO);
return 0; return 0;
} }
static int static int
virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps, virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os,
virDomainCapsOSPtr os,
char **loader, char **loader,
size_t nloader) size_t nloader)
{ {
virDomainCapsLoaderPtr capsLoader = &os->loader; virDomainCapsLoaderPtr capsLoader = &os->loader;
os->supported = true; os->supported = true;
if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, capsLoader, if (virQEMUCapsFillDomainLoaderCaps(capsLoader, loader, nloader) < 0)
loader, nloader) < 0)
return -1; return -1;
return 0; return 0;
} }
@ -4358,8 +4354,7 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
domCaps->maxvcpus = maxvcpus; domCaps->maxvcpus = maxvcpus;
if (virQEMUCapsFillDomainOSCaps(qemuCaps, os, if (virQEMUCapsFillDomainOSCaps(os, loader, nloader) < 0 ||
loader, nloader) < 0 ||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
domCaps->machine, disk) < 0 || domCaps->machine, disk) < 0 ||
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 || virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 ||

View File

@ -1393,8 +1393,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) && disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
disk->bus != VIR_DOMAIN_DISK_BUS_IDE) disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
virBufferAddLit(&opt, ",boot=on"); virBufferAddLit(&opt, ",boot=on");
if (disk->src->readonly && if (disk->src->readonly) {
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) { if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@ -4608,8 +4607,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
} }
char * char *
qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
virQEMUCapsPtr qemuCaps)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *source = NULL; char *source = NULL;
@ -4628,16 +4626,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
virDomainDeviceAddressTypeToString(dev->info->type), virDomainDeviceAddressTypeToString(dev->info->type),
dev->info->alias); dev->info->alias);
if (dev->readonly) { if (dev->readonly)
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) { virBufferAddLit(&buf, ",readonly=on");
virBufferAddLit(&buf, ",readonly=on");
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support 'readonly' "
"for -drive"));
goto error;
}
}
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto error; goto error;
@ -5040,7 +5030,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
char *drvstr; char *drvstr;
virCommandAddArg(cmd, "-drive"); virCommandAddArg(cmd, "-drive");
if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps))) if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
return -1; return -1;
virCommandAddArg(cmd, drvstr); virCommandAddArg(cmd, drvstr);
VIR_FREE(drvstr); VIR_FREE(drvstr);
@ -8775,13 +8765,6 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
unit++; unit++;
if (loader->readonly) { if (loader->readonly) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support passing "
"readonly attribute"));
goto cleanup;
}
virBufferAsprintf(&buf, ",readonly=%s", virBufferAsprintf(&buf, ",readonly=%s",
virTristateSwitchTypeToString(loader->readonly)); virTristateSwitchTypeToString(loader->readonly));
} }

View File

@ -161,8 +161,7 @@ char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev);
virQEMUCapsPtr qemuCaps);
char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,

View File

@ -1928,7 +1928,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0) if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0)
goto cleanup; goto cleanup;
if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps))) if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
goto cleanup; goto cleanup;
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))