qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Online resize of virtio-blk device does not emit udev e


From: Milos Vyletel
Subject: Re: [Qemu-devel] Online resize of virtio-blk device does not emit udev event
Date: Wed, 20 Feb 2013 21:34:45 +0100 (CET)

Stefan,

that's essentially what I was trying to do. I wanted to get an opinion from
someone more familiar with the virtio-blk and kernel in general firs though.

It looks like none of the block drivers handle this. It may be good idea to
add some function to block/genhd.c where similar stuff already exists
(media_change_notify_thread() for example). 

In the meantime I've done some proof of concept work directly in virtio-blk
driver where I'm emitting uevent when disk is resized.

What I'm trying to do is basically automatically handle resizing of filesystem
on guest in case host resizes block device for guest. This kernel patch along
with simple udev rules takes care of it.

--- drivers/block/virtio_blk.c.orig 2013-02-20 11:14:54.000000000 -0500
+++ drivers/block/virtio_blk.c  2013-02-20 13:34:15.000000000 -0500
@@ -294,6 +294,8 @@ static void virtblk_config_changed_work(
    struct virtio_device *vdev = vblk->vdev;
    struct request_queue *q = vblk->disk->queue;
    char cap_str_2[10], cap_str_10[10];
+   char event[] = "RESIZE=1";
+   char *envp[] = { event, NULL };
    u64 capacity, size;

    mutex_lock(&vblk->config_lock);
@@ -323,6 +325,7 @@ static void virtblk_config_changed_work(

    set_capacity(vblk->disk, capacity);
    revalidate_disk(vblk->disk);
+   kobject_uevent_env(&disk_to_dev(vblk->disk)->kobj, KOBJ_CHANGE, envp);
 done:
    mutex_unlock(&vblk->config_lock);
 }

# cat /etc/udev/rules.d/98-virtio-resize.rules
ACTION=="change", KERNEL=="vd*", \
        ENV{RESIZE}=="1", \
        ENV{ID_FS_TYPE}=="ext[3-4]", \
        RUN+="/sbin/resize2fs /dev/%k"
ACTION=="change", KERNEL=="vd*", \
        ENV{RESIZE}=="1", \
        ENV{ID_FS_TYPE}=="LVM2_member", \
        RUN+="/sbin/pvresize /dev/%k"

Milos

----- Original Message -----
From: "Stefan Hajnoczi" <address@hidden>
To: "Milos Vyletel" <address@hidden>
Cc: address@hidden
Sent: Wednesday, February 20, 2013 4:47:34 AM
Subject: Re: [Qemu-devel] Online resize of virtio-blk device does not emit udev 
event

On Tue, Feb 19, 2013 at 10:15:32PM +0100, Milos Vyletel wrote:
> I was looking at the virtblk_config_changed_work function in RHEL6.3 kernel's
> drivers/block/virtio_blk.c which I believe is the function handling 
> blockresize
> and it does not look like it tries to emit any kobject uevent.
> 
> Before I jump into patching kernel my question is whether it makes sense to 
> have
> such uevent? I surely can use a way how to detect capacity change from 
> userspace.

I suggest checking how other block drivers (including the device-mapper
and scsi layers) handle resize.  Perhaps virtio_blk.c can follow an
existing approach.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]