Block patches for 1.2-rc1
The following changes since commit 731dc9ecd4f2c3041538f7eb2d10eee0cb82da1b:
Update version to 1.2.0-rc0 (2012-08-16 13:56:34 -0500)
are available in the git repository at:
http://repo.or.cz/r/qemu/kevin.git for-anthony
Kevin Wolf (3):
vmdk: Fix header structure
vmdk: Read footer for streamOptimized images
Documentation: Warn against qemu-img on active image
Stefan Hajnoczi (1):
virtio-blk: hide VIRTIO_BLK_F_CONFIG_WCE from old machine types
block/vmdk.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- hw/pc_piix.c | 4 +++ hw/virtio-blk.c | 4 ++- hw/virtio-blk.h | 1 + hw/virtio-pci.c | 1 + qemu-img.texi | 8 +++++++ 6 files changed, 74 insertions(+), 2 deletions(-)
PATCH 1/4 vmdk: Fix header structure
Commit bb45ded9 swapped gd_offset and rgd_offset. This is wrong.
--- block/vmdk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/vmdk.c +1 -1
@@ -57,8 +57,8 @@ typedef struct {int64_t desc_offset;int64_t desc_size;int32_t num_gtes_per_gte; -int64_t gd_offset;int64_t rgd_offset; +int64_t gd_offset;int64_t grain_offset;char filler[1 ];char check_bytes[4 ];
Signature · 1 line
1.7.6.5
PATCH 2/4 vmdk: Read footer for streamOptimized images
In reply to Kevin WolfThe footer takes precedence over the header when it exists. It contains the real grain directory offset that is missing in the header. Without this patch, streamOptimized images with a footer cannot be read.
--- block/vmdk.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
block/vmdk.c +56 -0
@@ -35,6 +35,7 @@#define VMDK4_FLAG_RGD (1 << 1)#define VMDK4_FLAG_COMPRESS (1 << 16)#define VMDK4_FLAG_MARKER (1 << 17) +#define VMDK4_GD_AT_END 0xffffffffffffffffULL typedef struct { uint32_t version;
@@ -115,6 +116,13 @@ typedef struct VmdkGrainMarker {uint8_t data[0 ]; } VmdkGrainMarker; +enum { +MARKER_END_OF_STREAM =0 , +MARKER_GRAIN_TABLE =1 , +MARKER_GRAIN_DIRECTORY =2 , +MARKER_FOOTER =3 , +}; +static int vmdk_probe (const uint8_t *buf,int buf_size,const char *filename) {uint32_t magic;
@@ -451,6 +459,54 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,if (header.capacity ==0 && header.desc_offset) {return vmdk_open_desc_file (bs, flags, header.desc_offset <<9 ); } + +if (le64_to_cpu (header.gd_offset) ==VMDK4_GD_AT_END ) { +/* +* The footer takes precedence over the header, so read it in. The +* footer starts at offset -1024 from the end: One sector for the +* footer, and another one for the end-of-stream marker. +*/ +struct { +struct { +uint64_t val; +uint32_t size; +uint32_t type; +uint8_t pad[512 -16 ]; + } QEMU_PACKED footer_marker; + +uint32_t magic; +VMDK4Header header; +uint8_t pad[512 -4 -sizeof (VMDK4Header)]; + +struct { +uint64_t val; +uint32_t size; +uint32_t type; +uint8_t pad[512 -16 ]; + } QEMU_PACKED eos_marker; + } QEMU_PACKED footer; + + ret =bdrv_pread (file, + bs->file->total_sectors *512 -1536 , + &footer,sizeof (footer)); +if (ret <0 ) { +return ret; + } + +/* Some sanity checks for the footer */ +if (be32_to_cpu (footer.magic) !=VMDK4_MAGIC || +le32_to_cpu (footer.footer_marker.size) !=0 || +le32_to_cpu (footer.footer_marker.type) !=MARKER_FOOTER || +le64_to_cpu (footer.eos_marker.val) !=0 || +le32_to_cpu (footer.eos_marker.size) !=0 || +le32_to_cpu (footer.eos_marker.type) !=MARKER_END_OF_STREAM ) + { +return -EINVAL ; + } + + header = footer.header; + } + l1_entry_sectors =le32_to_cpu (header.num_gtes_per_gte) *le64_to_cpu (header.granularity);if (l1_entry_sectors ==0 ) {
Signature · 1 line
1.7.6.5
PATCH 3/4 Documentation: Warn against qemu-img on active image
In reply to Kevin WolfPeople have repeatedly expected that you can do things like snapshotting an image with qemu-img while a qemu instance is running. Maybe we need to consider locking the files while they are in use, but having a warning in the qemu-img manpage is doable for 1.2 and can't hurt anyway.
--- qemu-img.texi | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
qemu-img.texi +8 -0
@@ -4,6 +4,14 @@ usage: qemu-img command [command options] @c man end @end example +@c man begin DESCRIPTION +qemu-img allows you to create, convert and modify images offline. It can handle +all image formats supported by QEMU. + +@b{Warning:} Never use qemu-img to modify images in use by a running virtual +machine or any other process; this may destroy the image. +@c man end + @c man begin OPTIONS The following commands are supported:
Signature · 1 line
1.7.6.5
PATCH 4/4 virtio-blk: hide VIRTIO_BLK_F_CONFIG_WCE from old machine types
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
QEMU has a policy of keeping a stable guest device ABI. When new guest device features are introduced they must not change hardware info seen by existing guests. This is important because operating systems or applications may "fingerprint" the hardware and refuse to run when the hardware changes. To always get the latest guest device ABI, run with x86 machine type "pc".
This patch hides the new VIRTIO_BLK_F_CONFIG_WCE virtio feature bit from existing machine types. Only pc-1.2 and later will expose this feature by default.
For more info on the VIRTIO_BLK_F_CONFIG_WCE feature bit, see:
commit 13e3dce068773c971ff2f19d986378c55897c4a3
Author: Paolo Bonzini <[email protected]>
Date: Thu Aug 9 16:07:19 2012 +0200
virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
Also rename VIRTIO_BLK_F_WCACHE to VIRTIO_BLK_F_WCE for consistency with the spec.
Anthony Liguori <[email protected]> reported:
This broke qemu-test because it changed the pc-1.0 machine type:
Setting guest RANDOM seed to 47167
*** Running tests ***
Running test /tests/finger-print.sh... OK
--- fingerprints/pc-1.0.x86_64 2011-12-18 13:08:40.000000000 -0600
+++ fingerprint.txt 2012-08-12 13:30:48.000000000 -0500
@@ -55,7 +55,7 @@
/sys/bus/pci/devices/0000:00:06.0/subsystem_device=0x0002 /sys/bus/pci/devices/0000:00:06.0/class=0x010000 /sys/bus/pci/devices/0000:00:06.0/revision=0x00
-/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x710006d4 +/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x71000ed4
/sys/class/dmi/id/bios_vendor=Bochs /sys/class/dmi/id/bios_date=01/01/2007 /sys/class/dmi/id/bios_version=Bochs
Guest fingerprint changed for pc-1.0!
--- hw/pc_piix.c | 4 ++++ hw/virtio-blk.c | 4 +++- hw/virtio-blk.h | 1 + hw/virtio-pci.c | 1 + 4 files changed, 9 insertions(+), 1 deletions(-)
hw/pc_piix.c +4 -0
@@ -375,6 +375,10 @@ static QEMUMachine pc_machine_v1_2 = { .driver = "qxl",\ .property = "vgamem_mb",\ .value = stringify(8),\ + },{\ + .driver = "virtio-blk-pci",\ + .property = "config-wce",\ + .value = "off",\ }static QEMUMachine pc_machine_v1_1 = {
hw/virtio-blk.c +3 -1
@@ -533,7 +533,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 <<VIRTIO_BLK_F_BLK_SIZE ); features |= (1 <<VIRTIO_BLK_F_SCSI ); - features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); +if (s->blk->config_wce) { + features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); + }if (bdrv_enable_write_cache (s->bs)) features |= (1 <<VIRTIO_BLK_F_WCE );
hw/virtio-blk.h +1 -0
@@ -104,6 +104,7 @@ struct VirtIOBlkConfBlockConf conf;char *serial;uint32_t scsi; +uint32_t config_wce; };#define DEFINE_VIRTIO_BLK_FEATURES (_state, _field) \
hw/virtio-pci.c +1 -0
@@ -886,6 +886,7 @@ static Property virtio_blk_properties[] = {#ifdef __linux__DEFINE_PROP_BIT ("scsi" , VirtIOPCIProxy, blk.scsi,0 , true), #endif +DEFINE_PROP_BIT ("config-wce" , VirtIOPCIProxy, blk.config_wce,0 , true),DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true),DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors,2 ), DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
Signature · 1 line
1.7.6.5
Re: [Qemu-devel] [PATCH 4/4] virtio-blk: hide VIRTIO_BLK_F_CONFIG_WCE from old machine types
Il 17/08/2012 21:25, Kevin Wolf ha scritto:
Quoted 104 lines
From: Stefan Hajnoczi <[email protected]>
QEMU has a policy of keeping a stable guest device ABI. When new guest device features are introduced they must not change hardware info seen by existing guests. This is important because operating systems or applications may "fingerprint" the hardware and refuse to run when the hardware changes. To always get the latest guest device ABI, run with x86 machine type "pc".
This patch hides the new
VIRTIO_BLK_F_CONFIG_WCEvirtio feature bit from existing machine types. Only pc-1.2 and later will expose this feature by default.For more info on the
VIRTIO_BLK_F_CONFIG_WCEfeature bit, see:commit
13e3dce068773c971ff2f19d986378c55897c4a3
Author: Paolo Bonzini <[email protected]>
Date: Thu Aug 9 16:07:19 2012 +0200virtio-blk: support
VIRTIO_BLK_F_CONFIG_WCEAlso rename
VIRTIO_BLK_F_WCACHEtoVIRTIO_BLK_F_WCEfor consistency with the spec.Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Anthony Liguori <[email protected]> reported:
This broke qemu-test because it changed the pc-1.0 machine type:
Setting guest RANDOM seed to 47167
*** Running tests ***
Running test /tests/finger-print.sh... OK
--- fingerprints/pc-1.0.x86_64 2011-12-18 13:08:40.000000000 -0600
+++ fingerprint.txt 2012-08-12 13:30:48.000000000 -0500
@@ -55,7 +55,7 @@
/sys/bus/pci/devices/0000:00:06.0/subsystem_device=0x0002 /sys/bus/pci/devices/0000:00:06.0/class=0x010000 /sys/bus/pci/devices/0000:00:06.0/revision=0x00
-/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x710006d4 +/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x71000ed4
/sys/class/dmi/id/bios_vendor=Bochs /sys/class/dmi/id/bios_date=01/01/2007 /sys/class/dmi/id/bios_version=Bochs
Guest fingerprint changed for pc-1.0!Reported-by Anthony Liguori <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- hw/pc_piix.c | 4 ++++ hw/virtio-blk.c | 4 +++- hw/virtio-blk.h | 1 + hw/virtio-pci.c | 1 + 4 files changed, 9 insertions(+), 1 deletions(-)hw/pc_piix.c +4
-0@@ -375,6 +375,10 @@ static QEMUMachine pc_machine_v1_2 = { .driver = "qxl",\ .property = "vgamem_mb",\ .value = stringify(8),\ + },{\ + .driver = "virtio-blk-pci",\ + .property = "config-wce",\ + .value = "off",\ }static QEMUMachine pc_machine_v1_1 = {hw/virtio-blk.c +3
-1@@ -533,7 +533,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 <<VIRTIO_BLK_F_BLK_SIZE ); features |= (1 <<VIRTIO_BLK_F_SCSI ); - features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); +if (s->blk->config_wce) { + features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); + }if (bdrv_enable_write_cache (s->bs)) features |= (1 <<VIRTIO_BLK_F_WCE );hw/virtio-blk.h +1
-0@@ -104,6 +104,7 @@ struct VirtIOBlkConfBlockConf conf;char *serial;uint32_t scsi; +uint32_t config_wce; };#define DEFINE_VIRTIO_BLK_FEATURES (_state, _field) \hw/virtio-pci.c +0
-0
hw/virtio-pci.c static Property virtio_blk_properties[] = { · line 892
Quoted 7 lines
hw/virtio-pci.c +1
-0@@ -886,6 +886,7 @@ static Property virtio_blk_properties[] = {#ifdef __linux__DEFINE_PROP_BIT ("scsi" , VirtIOPCIProxy, blk.scsi,0 , true), #endif +DEFINE_PROP_BIT ("config-wce" , VirtIOPCIProxy, blk.config_wce,0 , true),DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true),DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors,2 ), DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
Could/should this be added to DEFINE_VIRTIO_BLK_FEATURES instead? You don't need the new field, and virtio_blk_get_features can simply omit VIRTIO_BLK_F_CONFIG_WCE. At least that's how virtio-net does it.
It can be done in 1.3 though.
Paolo
Re: [Qemu-devel] [PATCH 4/4] virtio-blk: hide VIRTIO_BLK_F_CONFIG_WCE from old machine types
Quoted 117 lines · Paolo Bonzini
Il 17/08/2012 21:25, Kevin Wolf ha scritto:
Quoted 104 lines
From: Stefan Hajnoczi <[email protected]>
QEMU has a policy of keeping a stable guest device ABI. When new guest device features are introduced they must not change hardware info seen by existing guests. This is important because operating systems or applications may "fingerprint" the hardware and refuse to run when the hardware changes. To always get the latest guest device ABI, run with x86 machine type "pc".
This patch hides the new
VIRTIO_BLK_F_CONFIG_WCEvirtio feature bit from existing machine types. Only pc-1.2 and later will expose this feature by default.For more info on the
VIRTIO_BLK_F_CONFIG_WCEfeature bit, see:commit
13e3dce068773c971ff2f19d986378c55897c4a3
Author: Paolo Bonzini <[email protected]>
Date: Thu Aug 9 16:07:19 2012 +0200virtio-blk: support
VIRTIO_BLK_F_CONFIG_WCEAlso rename
VIRTIO_BLK_F_WCACHEtoVIRTIO_BLK_F_WCEfor consistency with the spec.Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Anthony Liguori <[email protected]> reported:
This broke qemu-test because it changed the pc-1.0 machine type:
Setting guest RANDOM seed to 47167
*** Running tests ***
Running test /tests/finger-print.sh... OK
--- fingerprints/pc-1.0.x86_64 2011-12-18 13:08:40.000000000 -0600
+++ fingerprint.txt 2012-08-12 13:30:48.000000000 -0500 @@ -55,7 +55,7 @@
/sys/bus/pci/devices/0000:00:06.0/subsystem_device=0x0002 /sys/bus/pci/devices/0000:00:06.0/class=0x010000 /sys/bus/pci/devices/0000:00:06.0/revision=0x00
-/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x710006d4 +/sys/bus/pci/devices/0000:00:06.0/virtio/host-features=0x71000ed4
/sys/class/dmi/id/bios_vendor=Bochs /sys/class/dmi/id/bios_date=01/01/2007 /sys/class/dmi/id/bios_version=Bochs
Guest fingerprint changed for pc-1.0!Reported-by Anthony Liguori <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- hw/pc_piix.c | 4 ++++ hw/virtio-blk.c | 4 +++- hw/virtio-blk.h | 1 + hw/virtio-pci.c | 1 + 4 files changed, 9 insertions(+), 1 deletions(-)hw/pc_piix.c +4
-0@@ -375,6 +375,10 @@ static QEMUMachine pc_machine_v1_2 = { .driver = "qxl",\ .property = "vgamem_mb",\ .value = stringify(8),\ + },{\ + .driver = "virtio-blk-pci",\ + .property = "config-wce",\ + .value = "off",\ }static QEMUMachine pc_machine_v1_1 = {hw/virtio-blk.c +3
-1@@ -533,7 +533,9 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 <<VIRTIO_BLK_F_BLK_SIZE ); features |= (1 <<VIRTIO_BLK_F_SCSI ); - features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); +if (s->blk->config_wce) { + features |= (1 <<VIRTIO_BLK_F_CONFIG_WCE ); + }if (bdrv_enable_write_cache (s->bs)) features |= (1 <<VIRTIO_BLK_F_WCE );hw/virtio-blk.h +1
-0@@ -104,6 +104,7 @@ struct VirtIOBlkConfBlockConf conf;char *serial;uint32_t scsi; +uint32_t config_wce; };#define DEFINE_VIRTIO_BLK_FEATURES (_state, _field) \hw/virtio-pci.c +0
-0hw/virtio-pci.c static Property virtio_blk_properties[] = { · line 892
Quoted 7 lines
hw/virtio-pci.c +1
-0@@ -886,6 +886,7 @@ static Property virtio_blk_properties[] = {#ifdef __linux__DEFINE_PROP_BIT ("scsi" , VirtIOPCIProxy, blk.scsi,0 , true), #endif +DEFINE_PROP_BIT ("config-wce" , VirtIOPCIProxy, blk.config_wce,0 , true),DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true),DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors,2 ), DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),Could/should this be added to
DEFINE_VIRTIO_BLK_FEATURESinstead? You don't need the new field, andvirtio_blk_get_featurescan simply omitVIRTIO_BLK_F_CONFIG_WCE. At least that's how virtio-net does it.
Quoted 1 line
It can be done in 1.3 though.
Sounds nice, will send a patch for 1.3. No user-visible change.
Stefan