[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: To start multiple KVM guests from one qcow2 image with transient dis
From: |
Peter Krempa |
Subject: |
Re: To start multiple KVM guests from one qcow2 image with transient disk option |
Date: |
Tue, 5 Jan 2021 15:12:55 +0100 |
User-agent: |
Mutt/1.14.6 (2020-07-11) |
On Mon, Jan 04, 2021 at 15:30:19 -0500, Masayoshi Mizuma wrote:
> On Sat, Dec 19, 2020 at 11:30:39PM -0500, Masayoshi Mizuma wrote:
[...]
> I think following qemu command line options and QMP commands work for sharing
> the qcow2 disks. The following uses disk hotplug instead of snapshot overlay.
> Does that make sense for libvirt...?
>
> qemu command line options:
So you are proposing to ...
>
> qemu-system-x86_64 \
> -M q35,accel=kvm,usb=off,vmport=off,smm=on,dump-guest-core=off \
> -smp 1 \
> -m 4096 \
> -blockdev
> '{"driver":"file","filename":"/home/mmizuma/debug/guest.qcow2","node-name":"storage1","auto-read-only":true,"discard":"unmap"}'
> \
> -blockdev
> '{"node-name":"format1","read-only":true,"driver":"qcow2","file":"storage1","backing":null}'
> \
... start with the disk already in 'read-only' mode _and_ skip addition
of the disk ...
> -nographic \
> -nodefaults \
> -no-user-config \
> -serial telnet::10000,server,nowait \
> -qmp tcp::10001,server,nowait \
> -S \
> -device pcie-root-port,id=pci.1
>
> QMP commands:
>
> {"execute":"qmp_capabilities"}
>
> {"execute":"blockdev-add","arguments":{"driver":"file","filename":"/var/lib/libvirt/images/guest.TRANSIENT","node-name":"storage2","auto-read-only":true,"discard":"unmap"}}
>
> {"execute":"blockdev-create","arguments":{"job-id":"create","options":{"driver":"qcow2","file":"storage2","size":4294967296,"cluster-size":65536,"backing-file":"/var/lib/libvirt/images/guest.TRANSIENT","backing-fmt":"qcow2"}}}
>
> {"execute":"blockdev-add","arguments":{"node-name":"format2","read-only":false,"driver":"qcow2","file":"storage2"}}
... and then add a writable overlay ...
>
> {"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"format2","id":"transient-disk","bootindex":1,"bus":"pci.1","addr":0}}
... and hotplug the disk.
> {"execute":"cont"}
So that is a no-go. Some disk bus-es such as IDE don't support hotplug:
https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_hotplug.c#L1074
You could try to just instantiate the backend of the disk as read-only,
and then create a writable overlay. You just need to make sure that the
disk will be writable and that it works even for IDE/SATA which doesn't
support read-only:
https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_validate.c#L2634