提交 b340c6c6 编写于 作者: D Daniel P. Berrangé

qemu: format serial and geometry on frontend disk device

Currently we format the serial, geometry and error policy on the -drive
backend argument.

QEMU added the ability to set serial and geometry on the frontend in
the 1.2 release deprecating use of -drive, with support being deleted
from -drive in 3.0.

We keep formatting error policy on -drive for now, because we don't
ahve support for that with -device for usb-storage just yet.

Note that some disk buses (sd) still don't support -device. Although
QEMU allowed these properties to be set on -drive for if=sd, they
have been ignored so we now report an error in this case.
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 33a47505
......@@ -1613,7 +1613,7 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
disk->geometry.sectors);
if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
virBufferAsprintf(buf, ",trans=%s",
virBufferAsprintf(buf, ",bios-chs-trans=%s",
virDomainDiskGeometryTransTypeToString(disk->geometry.trans));
}
......@@ -1621,8 +1621,6 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
virBufferAddLit(buf, ",serial=");
virBufferEscape(buf, '\\', " ", "%s", disk->serial);
}
qemuBuildDiskFrontendAttributeErrorPolicy(disk, buf);
}
......@@ -1664,9 +1662,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
virBufferAsprintf(&opt, ",index=%d", idx);
}
/* Format attributes for the drive itself (not the storage backing it) which
* we've formatted historically with -drive */
qemuBuildDiskFrontendAttributes(disk, &opt);
/* werror/rerror are really frontend attributes, but older
* qemu requires them on -drive instead of -device */
qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt);
/* While this is a frontend attribute, it only makes sense to be used when
* legacy -drive is used. In modern qemu the 'ide-cd' or 'scsi-cd' are used.
......@@ -2125,6 +2124,8 @@ qemuBuildDriveDevStr(const virDomainDef *def,
if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0)
goto error;
qemuBuildDiskFrontendAttributes(disk, &opt);
if (virBufferCheckError(&opt) < 0)
goto error;
......
......@@ -4657,6 +4657,33 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
}
}
if (disk->geometry.cylinders > 0 &&
disk->geometry.heads > 0 &&
disk->geometry.sectors > 0) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB ||
disk->bus == VIR_DOMAIN_DISK_BUS_SD) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("CHS geometry can not be set for '%s' bus"),
virDomainDiskBusTypeToString(disk->bus));
return -1;
}
if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT &&
disk->bus != VIR_DOMAIN_DISK_BUS_IDE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("CHS translation mode can only be set for 'ide' bus not '%s'"),
virDomainDiskBusTypeToString(disk->bus));
return -1;
}
}
if (disk->serial && disk->bus == VIR_DOMAIN_DISK_BUS_SD) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Serial property not supported for drive bus '%s'"),
virDomainDiskBusTypeToString(disk->bus));
return -1;
}
if (driverName && STRNEQ(driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"),
......
......@@ -28,22 +28,22 @@ server,nowait \
-drive file.driver=vxhs,file.tls-creds=objvirtio-disk0_tls0,\
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
file.server.host=192.168.0.1,file.server.port=9999,format=raw,if=none,\
id=drive-virtio-disk0,serial=eb90327c-8302-4725-9e1b-4e85ed4dc251,cache=none \
id=drive-virtio-disk0,cache=none \
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
id=virtio-disk0 \
id=virtio-disk0,serial=eb90327c-8302-4725-9e1b-4e85ed4dc251 \
-object tls-creds-x509,id=objvirtio-disk1_tls0,dir=/etc/pki/libvirt-vxhs/dummy,\
,path,endpoint=client,verify-peer=yes \
-drive file.driver=vxhs,file.tls-creds=objvirtio-disk1_tls0,\
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc252,\
file.server.host=192.168.0.2,file.server.port=9999,format=raw,if=none,\
id=drive-virtio-disk1,serial=eb90327c-8302-4725-9e1b-4e85ed4dc252,cache=none \
id=drive-virtio-disk1,cache=none \
-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\
id=virtio-disk1 \
id=virtio-disk1,serial=eb90327c-8302-4725-9e1b-4e85ed4dc252 \
-drive file.driver=vxhs,file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc253,\
file.server.host=192.168.0.3,file.server.port=9999,format=raw,if=none,\
id=drive-virtio-disk2,serial=eb90327c-8302-4725-9e1b-4e85ed4dc252,cache=none \
id=drive-virtio-disk2,cache=none \
-device virtio-blk-pci,bus=pci.0,addr=0x6,drive=drive-virtio-disk2,\
id=virtio-disk2 \
id=virtio-disk2,serial=eb90327c-8302-4725-9e1b-4e85ed4dc252 \
-object tls-creds-x509,id=objvirtio-disk3_tls0,dir=/etc/pki/libvirt-nbd/dummy,,\
path,endpoint=client,verify-peer=yes \
-drive file.driver=nbd,file.server.type=inet,file.server.host=example.com,\
......
......@@ -25,6 +25,6 @@ server,nowait \
-usb \
-drive file.driver=vxhs,file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
file.server.host=192.168.0.1,file.server.port=9999,format=raw,if=none,\
id=drive-virtio-disk0,serial=eb90327c-8302-4725-9e1b-4e85ed4dc251,cache=none \
id=drive-virtio-disk0,cache=none \
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
id=virtio-disk0
id=virtio-disk0,serial=eb90327c-8302-4725-9e1b-4e85ed4dc251
......@@ -23,8 +23,9 @@ server,nowait \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0,\
serial=XYZXYZXYZYXXYZYZYXYZY,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
serial=XYZXYZXYZYXXYZYZYXYZY \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
media=cdrom,readonly=on \
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
......
......@@ -22,7 +22,7 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0,\
cyls=16383,heads=16,secs=63,trans=lba \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,cyls=16383,\
heads=16,secs=63,bios-chs-trans=lba \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
......@@ -22,8 +22,7 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\
serial=WD-WMAP9A966149 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \
-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\
wwn=0x5000c50015ea71ad \
wwn=0x5000c50015ea71ad,serial=WD-WMAP9A966149 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
......@@ -25,9 +25,9 @@ server,nowait \
-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-1-0,\
serial=WD-WMAP9A966149,readonly=on \
readonly=on \
-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,\
id=scsi0-0-1-0,wwn=0x5000c50015ea71ac \
id=scsi0-0-1-0,wwn=0x5000c50015ea71ac,serial=WD-WMAP9A966149 \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-scsi0-0-0-0 \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,\
id=scsi0-0-0-0,wwn=0x5000c50015ea71ad \
......
......@@ -22,11 +22,11 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
-drive 'file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \
-device 'ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\
serial=\ \ WD-WMAP9A966149' \
-device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
-drive 'file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2,\
-drive file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2 \
-device 'ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2,\
serial=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_\ .+' \
-device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
-drive file=/some/file,format=raw,if=sd,index=0,serial=sdserial \
-drive file=/some/file,format=raw,if=sd,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
......@@ -29,7 +29,6 @@
<disk type='file' device='disk'>
<source file='/some/file'/>
<target dev='sda' bus='sd'/>
<serial>sdserial</serial>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
......
......@@ -32,7 +32,6 @@
<driver name='qemu' type='raw'/>
<source file='/some/file'/>
<target dev='sda' bus='sd'/>
<serial>sdserial</serial>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册