mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-30 16:35:24 +00:00
Introduce <readonly> for hostdev
Since it's generic enough to be used by other types in future, I put it in <hostdev> as sub-element, though now it's only used by scsi host device.
This commit is contained in:
parent
dcd632af72
commit
f4bb7b4807
@ -2415,6 +2415,10 @@
|
|||||||
could be changed in the future with no impact to domains that
|
could be changed in the future with no impact to domains that
|
||||||
don't specify anything.
|
don't specify anything.
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><code>readonly</code></dt>
|
||||||
|
<dd>Indicates that the device is readonly, only supported by SCSI host
|
||||||
|
device now. <span class="since">Since 1.0.6 (QEMU and KVM only)</span>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
@ -3075,6 +3075,11 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<ref name="address"/>
|
<ref name="address"/>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<element name="readonly">
|
||||||
|
<empty/>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
</interleave>
|
</interleave>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
@ -8730,6 +8730,9 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
|
|||||||
_("SCSI host devices must have address specified"));
|
_("SCSI host devices must have address specified"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virXPathBoolean("boolean(./readonly)", ctxt))
|
||||||
|
def->readonly = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15358,6 +15361,9 @@ virDomainHostdevDefFormat(virBufferPtr buf,
|
|||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->readonly)
|
||||||
|
virBufferAddLit(buf, "<readonly/>\n");
|
||||||
virBufferAdjustIndent(buf, -6);
|
virBufferAdjustIndent(buf, -6);
|
||||||
|
|
||||||
if (virDomainDeviceInfoFormat(buf, def->info,
|
if (virDomainDeviceInfoFormat(buf, def->info,
|
||||||
|
@ -461,6 +461,7 @@ struct _virDomainHostdevDef {
|
|||||||
int startupPolicy; /* enum virDomainStartupPolicy */
|
int startupPolicy; /* enum virDomainStartupPolicy */
|
||||||
bool managed;
|
bool managed;
|
||||||
bool missing;
|
bool missing;
|
||||||
|
bool readonly;
|
||||||
union {
|
union {
|
||||||
virDomainHostdevSubsys subsys;
|
virDomainHostdevSubsys subsys;
|
||||||
virDomainHostdevCaps caps;
|
virDomainHostdevCaps caps;
|
||||||
|
@ -4754,6 +4754,17 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
|
|||||||
virDomainDeviceAddressTypeToString(dev->info->type),
|
virDomainDeviceAddressTypeToString(dev->info->type),
|
||||||
dev->info->alias);
|
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 (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
|
||||||
|
pc -m 214 -smp 1 -nographic -nodefaults -monitor \
|
||||||
|
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
|
||||||
|
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \
|
||||||
|
-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 \
|
||||||
|
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||||
|
-drive file=/dev/sg0,if=none,id=drive-hostdev-scsi_host0-0-0-0,readonly=on \
|
||||||
|
-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=drive-hostdev-scsi_host0-0-0-0,id=hostdev-scsi_host0-0-0-0 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
|
@ -0,0 +1,36 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest2</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219100</memory>
|
||||||
|
<currentMemory unit='KiB'>219100</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest2'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='scsi' index='0' model='virtio-scsi'/>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<hostdev mode='subsystem' type='scsi' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<adapter name='scsi_host0'/>
|
||||||
|
<address bus='0' target='0' unit='0'/>
|
||||||
|
</source>
|
||||||
|
<readonly/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='4' unit='8'/>
|
||||||
|
</hostdev>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -985,6 +985,10 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
|
QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
|
||||||
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
|
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
|
||||||
QEMU_CAPS_DEVICE_SCSI_GENERIC);
|
QEMU_CAPS_DEVICE_SCSI_GENERIC);
|
||||||
|
DO_TEST("hostdev-scsi-readonly", QEMU_CAPS_DRIVE,
|
||||||
|
QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
|
||||||
|
QEMU_CAPS_DRIVE_READONLY, QEMU_CAPS_VIRTIO_SCSI,
|
||||||
|
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC);
|
||||||
|
|
||||||
virObjectUnref(driver.config);
|
virObjectUnref(driver.config);
|
||||||
virObjectUnref(driver.caps);
|
virObjectUnref(driver.caps);
|
||||||
|
@ -287,6 +287,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST("hostdev-scsi-lsi");
|
DO_TEST("hostdev-scsi-lsi");
|
||||||
DO_TEST("hostdev-scsi-virtio-scsi");
|
DO_TEST("hostdev-scsi-virtio-scsi");
|
||||||
|
DO_TEST("hostdev-scsi-readonly");
|
||||||
|
|
||||||
virObjectUnref(driver.caps);
|
virObjectUnref(driver.caps);
|
||||||
virObjectUnref(driver.xmlopt);
|
virObjectUnref(driver.xmlopt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user