How to remove/add a disk on a running KVM Virtual Machine

vcp_ai

Renowned Member
Jul 28, 2010
177
5
83
Valencia -Spain-
Hi, I'm new to linux software RAID, and trying to learn ...
To test configurations and specially responses after a problem, I've prepared a KVM virtual machine to test a Fileserver configuration, where a linux software RAID is used.

Machine is configured with 2 virtio disks, running on RAID1. Fileserver is running as expected, and now, I´m trying to remove one disk to see how linux software RAID1 performs, and when it happens, will try to add a new disk to see if it RAID can be re-created.

After reading qm monitor help it seems that drive_del / drive_add functions could do what I need ...

Is this correct, or should I use another funcion to 'hot remove-add' a disk on a virtual machine ???


When I use drive_del, with parameter virtio1, it 'hot-removes' the disk from the virtual machine, and it (debian) detects a failure on disk 2, as expected :p.

Now I'm trying to 'hot-add' this disk to the virtual machine but seems that i can not get the correct sintax for drive_add, and can not find more info ....
file for second disk is in storage local, machine 3010 i.e: local:3010/vm-3010-disk-2.raw

According to drive_add help I've tested:
Code:
qm> help drive_add
drive_add [[<domain>:]<bus>:]<slot>
[file=file][,if=type][,bus=n]
[,unit=m][,media=d][,index=i]
[,cyls=c,heads=h,secs=s[,trans=t]]
[,snapshot=on|off][,cache=on|off]
[,readonly=on|off][,copy-on-read=on|off] -- add drive to PCI storage controller

qm> drive_add virtio1
drive_add: string expected

qm> drive_add virtio1 file=local:3010/vm-3010-disk-2.raw
could not open disk image local:3010/vm-3010-disk-2.raw: No such file or directory

qm> drive_add virtio1 file=3010/vm-3010-disk-2.raw
could not open disk image 3010/vm-3010-disk-2.raw: No such file or directory

qm> drive_add virtio1 file=vm-3010-disk-2.raw
could not open disk image vm-3010-disk-2.raw: No such file or directory

Seems that I can not provide the current path for the raw disk..
Could somebody post the correct sintax for drive_add ?

Regards
 
Further investigation lend me to the correct path for the raw disk (I am at the proxmow server ! ) so current path is:
/var/lib/vz/images/3010/vm-3010-disk-2.raw

I assume that if is the interface type, in my case virtio.

ON guest vm result of lspcsi is:
Code:
root@debian-pve:/home/usuariopve# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB Controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:0a.0 SCSI storage controller: Red Hat, Inc Virtio block device
00:12.0 Ethernet controller: Red Hat, Inc Virtio network device
So I assume that bus is a and slot 1

So I tested some combinations with same result:

Code:
qm> drive_add 1 file=/var/lib/vz/images/3010/vm-3010-disk-2.raw,if=virtio
Can't hot-add drive to type 7

qm> drive_add a file=/var/lib/vz/images/3010/vm-3010-disk-2.raw,if=virtio
Can't hot-add drive to type 7

qm> drive_add a:1 file=/var/lib/vz/images/3010/vm-3010-disk-2.raw,if=virtio
Can't hot-add drive to type 7

qm> drive_add b:0 file=/var/lib/vz/images/3010/vm-3010-disk-2.raw,if=virtio
Can't hot-add drive to type 7

Can someone confirm that a virtio drive can be hot-added to qemu ??

Any other hint ?

Regards