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

View File

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

View File

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

View File

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