From dc80ca6cd6cafdee174af3c883d85e19b7fd70a5 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:29 +0800 Subject: virtio-blk: avoid qdev property definition duplication It becomes unwiedly to duplicate all virtio-blk qdev property definitions due to an #ifdef. The C preprocessor syntax makes it a little hard to resolve this cleanly but we can extract the #ifdef and call a macro it defines later. Avoiding duplication is important since it will only get worse when we move the x-data-plane qdev property here too. We'd have a combinatorial explosion since x-data-plane has its own #ifdef. Suggested-by: Peter Crosthwaite Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/virtio/virtio-blk.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index d0fb26f..ee43f7a 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -156,21 +156,19 @@ typedef struct VirtIOBlockReq { DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) #ifdef __linux__ -#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ - DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ - DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ - DEFINE_PROP_STRING("serial", _state, _field.serial), \ - DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ - DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), \ - DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) +#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ + DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), #else +#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) +#endif + #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ + DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ DEFINE_PROP_STRING("serial", _state, _field.serial), \ DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) -#endif /* __linux__ */ void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk); -- cgit v1.1 From ee512c6f21b2f76ae923e3a4cabbd58899ff7ae1 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:31 +0800 Subject: virtio-blk: move x-data-plane qdev property to virtio-blk.h Move the x-data-plane property. Originally it was outside since not every transport may wish to support dataplane. But that makes little sense when we have a dedicated CONFIG_VIRTIO_BLK_DATA_PLANE ifdef already. This move makes it easier to switch to property aliases in the next patch. Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/virtio/virtio-blk.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index ee43f7a..1d80bcc 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -162,8 +162,16 @@ typedef struct VirtIOBlockReq { #define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) #endif +#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE +#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \ + DEFINE_PROP_BIT("x-data-plane", _state, _field.data_plane, 0, false), +#else +#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) +#endif + #define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ + DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \ DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ DEFINE_PROP_STRING("serial", _state, _field.serial), \ -- cgit v1.1 From 67cc7e0aaca835ed68cf3bd34f4d51a21232792f Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:32 +0800 Subject: qdev: add qdev_alias_all_properties() The qdev_alias_all_properties() function creates QOM alias properties for each qdev property on a DeviceState. This is useful for parent objects that wish to forward property accesses to their children. Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/qdev-properties.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index c962b6b..3726bf3 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -193,6 +193,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, */ void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp); +void qdev_alias_all_properties(DeviceState *target, Object *source); + /** * @qdev_prop_set_after_realize: * @dev: device -- cgit v1.1 From f7fedda84a8eb316c99a9de647c4844b862a7b38 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:34 +0800 Subject: virtio-blk: drop virtio_blk_set_conf() This function is no longer used since parent objects now use child aliases to set the VirtIOBlkConf directly. Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/virtio/virtio-blk.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 1d80bcc..52e5add 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -178,8 +178,6 @@ typedef struct VirtIOBlockReq { DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) -void virtio_blk_set_conf(DeviceState *dev, VirtIOBlkConf *blk); - int virtio_blk_handle_scsi_req(VirtIOBlock *blk, VirtQueueElement *elem); -- cgit v1.1 From 32a877e4059ad7fd428bdd31d3e954fed72fa21b Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 18 Jun 2014 17:58:36 +0800 Subject: virtio-blk: move qdev properties into virtio-blk.c There is no need to make DEFINE_VIRTIO_BLK_PROPERTIES() public. Inline it into virtio-blk.c so it cannot be used by mistake from other source files. Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Crosthwaite --- include/hw/virtio/virtio-blk.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'include') diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 52e5add..223530e 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -155,29 +155,6 @@ typedef struct VirtIOBlockReq { #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \ DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) -#ifdef __linux__ -#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ - DEFINE_PROP_BIT("scsi", _state, _field.scsi, 0, true), -#else -#define DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) -#endif - -#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE -#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \ - DEFINE_PROP_BIT("x-data-plane", _state, _field.data_plane, 0, false), -#else -#define DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) -#endif - -#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _field) \ - DEFINE_VIRTIO_BLK_PROPERTIES_LINUX(_state, _field) \ - DEFINE_VIRTIO_BLK_PROPERTIES_DATA_PLANE(_state, _field) \ - DEFINE_BLOCK_PROPERTIES(_state, _field.conf), \ - DEFINE_BLOCK_CHS_PROPERTIES(_state, _field.conf), \ - DEFINE_PROP_STRING("serial", _state, _field.serial), \ - DEFINE_PROP_BIT("config-wce", _state, _field.config_wce, 0, true), \ - DEFINE_PROP_IOTHREAD("x-iothread", _state, _field.iothread) - int virtio_blk_handle_scsi_req(VirtIOBlock *blk, VirtQueueElement *elem); -- cgit v1.1 From 1351d1ec89eabebc9fdff20451a62c413d7accc1 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 10 Jun 2014 09:03:21 +0200 Subject: qdev: drop iothread property type The iothread property type is no longer used and can be removed. Signed-off-by: Stefan Hajnoczi --- include/hw/qdev-properties.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 3726bf3..77fe3a1 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -22,7 +22,6 @@ extern PropertyInfo qdev_prop_bios_chs_trans; extern PropertyInfo qdev_prop_drive; extern PropertyInfo qdev_prop_netdev; extern PropertyInfo qdev_prop_vlan; -extern PropertyInfo qdev_prop_iothread; extern PropertyInfo qdev_prop_pci_devfn; extern PropertyInfo qdev_prop_blocksize; extern PropertyInfo qdev_prop_pci_host_devaddr; @@ -143,8 +142,6 @@ extern PropertyInfo qdev_prop_arraylen; DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NICPeers) #define DEFINE_PROP_DRIVE(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *) -#define DEFINE_PROP_IOTHREAD(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_iothread, IOThread *) #define DEFINE_PROP_MACADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ -- cgit v1.1 From 4ab1559085d688dddf4de77f1ead3102e243e668 Mon Sep 17 00:00:00 2001 From: Chunyan Liu Date: Mon, 30 Jun 2014 14:29:58 +0800 Subject: qemu-img create: add 'nocow' option Add 'nocow' option so that users could have a chance to set NOCOW flag to newly created files. It's useful on btrfs file system to enhance performance. Btrfs has low performance when hosting VM images, even more when the guest in those VM are also using btrfs as file system. One way to mitigate this bad performance is to turn off COW attributes on VM files. Generally, there are two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, then all newly created files will be NOCOW. b) per file. Add the NOCOW file attribute. It could only be done to empty or new files. This patch tries the second way, according to the option, it could add NOCOW per file. For most block drivers, since the create file step is in raw-posix.c, so we can do setting NOCOW flag ioctl in raw-posix.c only. But there are some exceptions, like block/vpc.c and block/vdi.c, they are creating file by calling qemu_open directly. For them, do the same setting NOCOW flag ioctl work in them separately. [Fixed up 082.out due to the new 'nocow' creation option --Stefan] Signed-off-by: Chunyan Liu Signed-off-by: Stefan Hajnoczi --- include/block/block_int.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/block/block_int.h b/include/block/block_int.h index 53e77cf..eaf6e31 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -54,6 +54,7 @@ #define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts" #define BLOCK_OPT_ADAPTER_TYPE "adapter_type" #define BLOCK_OPT_REDUNDANCY "redundancy" +#define BLOCK_OPT_NOCOW "nocow" typedef struct BdrvTrackedRequest { BlockDriverState *bs; -- cgit v1.1 From 5a6684d2b957f9ec75d7ed7b14332293abec1d6c Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Wed, 25 Jun 2014 15:40:09 -0400 Subject: block: add helper function to determine if a BDS is in a chain This is a small helper function, to determine if 'base' is in the chain of BlockDriverState 'top'. It returns true if it is in the chain, and false otherwise. If either argument is NULL, it will also return false. Reviewed-by: Benoit Canet Reviewed-by: Eric Blake Signed-off-by: Jeff Cody Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- include/block/block.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 7e92f54..29c9e50 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -403,6 +403,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(void); BlockDriverState *bdrv_lookup_bs(const char *device, const char *node_name, Error **errp); +bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base); BlockDriverState *bdrv_next(BlockDriverState *bs); void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque); -- cgit v1.1 From 54e269009099cdc9483be115f1e12d56ad459c5e Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Wed, 25 Jun 2014 15:40:10 -0400 Subject: block: extend block-commit to accept a string for the backing file On some image chains, QEMU may not always be able to resolve the filenames properly, when updating the backing file of an image after a block commit. For instance, certain relative pathnames may fail, or drives may have been specified originally by file descriptor (e.g. /dev/fd/???), or a relative protocol pathname may have been used. In these instances, QEMU may lack the information to be able to make the correct choice, but the user or management layer most likely does have that knowledge. With this extension to the block-commit api, the user is able to change the backing file of the overlay image as part of the block-commit operation. This allows the change to be 'safe', in the sense that if the attempt to write the overlay image metadata fails, then the block-commit operation returns failure, without disrupting the guest. If the commit top is the active layer, then specifying the backing file string will be treated as an error (there is no overlay image to modify in that case). If a backing file string is not specified in the command, the backing file string to use is determined in the same manner as it was previously. Reviewed-by: Eric Blake Signed-off-by: Jeff Cody Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- include/block/block.h | 3 ++- include/block/block_int.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 29c9e50..baecc26 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -285,7 +285,8 @@ int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); void bdrv_register(BlockDriver *bdrv); int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, - BlockDriverState *base); + BlockDriverState *base, + const char *backing_file_str); BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs); BlockDriverState *bdrv_find_base(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index eaf6e31..8f8e65e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -463,13 +463,14 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base, * @on_error: The action to take upon error. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. + * @backing_file_str: String to use as the backing file in @top's overlay * @errp: Error object. * */ void commit_start(BlockDriverState *bs, BlockDriverState *base, BlockDriverState *top, int64_t speed, BlockdevOnError on_error, BlockDriverCompletionFunc *cb, - void *opaque, Error **errp); + void *opaque, const char *backing_file_str, Error **errp); /** * commit_active_start: * @bs: Active block device to be committed. -- cgit v1.1