[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command |
Date: |
Mon, 17 Jan 2011 18:36:15 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10 |
Am 14.01.2011 17:20, schrieb Christoph Hellwig:
> Add a monitor command that allows resizing of block devices while
> qemu is running. It uses the existing bdrv_truncate method already
> used by qemu-img to do it's work. Compared to qemu-img the size
> parsing is very simplicistic, but I think having a properly numering
> object is more useful for non-humand monitor users than having
> the units and relative resize parsing.
>
> For SCSI devices the new size can be updated in Linux guests by
> doing the following shell command:
>
> echo > /sys/class/scsi_device/0:0:0:0/device/rescan
>
> For ATA devices I don't know of a way to update the block device
> size in Linux system, and for virtio-blk the next two patches
> will provide an automatic update of the size when this command
> is issued on the host.
>
> Signed-off-by: Christoph Hellwig <address@hidden>
>
> Index: qemu/hmp-commands.hx
> ===================================================================
> --- qemu.orig/hmp-commands.hx 2011-01-14 15:11:48.527004132 +0100
> +++ qemu/hmp-commands.hx 2011-01-14 15:40:14.407006506 +0100
> @@ -53,6 +53,24 @@ Quit the emulator.
> ETEXI
>
> {
> + .name = "resize",
> + .args_type = "id:s,size:l",
size should be 'o' instead of 'l'. The latter may be too small on 32 bit
hosts and doesn't support convenient suffixes:
* 'l' target long (32 or 64 bit)
* 'o' octets (aka bytes)
* user mode accepts an optional T, t, G, g, M, m, K, k
* suffix, which multiplies the value by 2^40 for
* suffixes T and t, 2^30 for suffixes G and g, 2^20 for
* M and m, 2^10 for K and k
> + .params = "device size",
> + .help = "resize a block image",
> + .user_print = monitor_user_noop,
> + .mhandler.cmd_new = do_resize,
> + },
> +
> +STEXI
> address@hidden resize
> address@hidden resize
> +Resize a block image while a guest is running. Usuaully requires guest
> +action to see the updated size. Resize to a lower size is supported,
> +but should be used with extreme caution.
> +ETEXI
> +
> +
> + {
> .name = "eject",
> .args_type = "force:-f,device:B",
> .params = "[-f] device",
> Index: qemu/blockdev.c
> ===================================================================
> --- qemu.orig/blockdev.c 2011-01-14 15:11:48.539261151 +0100
> +++ qemu/blockdev.c 2011-01-14 15:50:35.604293558 +0100
> @@ -700,3 +700,41 @@ int do_drive_del(Monitor *mon, const QDi
>
> return 0;
> }
> +
> +int do_resize(Monitor *mon, const QDict *qdict, QObject **ret_data)
> +{
> + const char *id = qdict_get_str(qdict, "id");
> + int64_t size = qdict_get_int(qdict, "size");
> + BlockDriverState *bs;
> +
> + bs = bdrv_find(id);
> + if (!bs) {
> + qerror_report(QERR_DEVICE_NOT_FOUND, id);
> + return -1;
> + }
> +
> + if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) {
> + error_report("Can not resize CDROM devices\n");
> + return -1;
> + }
Hm, is there a real reason except that CD-ROMs are read-only? The code
below seems to take read-only devices into account.
Kevin
- [Qemu-devel] [PATCH 0/3] allow online resizing of block devices, Christoph Hellwig, 2011/01/14
- [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Christoph Hellwig, 2011/01/14
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Stefan Hajnoczi, 2011/01/17
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command,
Kevin Wolf <=
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Christoph Hellwig, 2011/01/18
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Christoph Hellwig, 2011/01/19
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Kevin Wolf, 2011/01/19
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Christoph Hellwig, 2011/01/19
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Kevin Wolf, 2011/01/19
- Re: [Qemu-devel] [PATCH 1/3] block: add resize monitor command, Christoph Hellwig, 2011/01/19
[Qemu-devel] [PATCH 2/3] block: tell drivers about an image resize, Christoph Hellwig, 2011/01/14
[Qemu-devel] [PATCH 3/3] virtio-blk: tell the guest about size changes, Christoph Hellwig, 2011/01/14