全部博文(389)
分类: 虚拟化
2014-12-29 16:34:55
Create a temporary file with a disk definition like this one below.
adjust the properties to fit your situation
Tip: Peek into your current XML domain configuration and copy a
virsh dumpxml
Now, before adding the disk to a current domain, make sure the required hotplug kernel modules are loaded in the guest.
Some Linux distributions like recent CentOS/RHEL/Fedora have this built-in in the kernel. In this case, check for CONFIG_HOTPLUG_PCI_ACPI. If it's y, then you're all set and you can skip this step.
modprobe acpiphp modprobe pci_hotplug
Consider adding these two modules to /etc/modules if you want them to be loaded on boot by default.
Add the disk it to the running VM using
virsh attach-device/path/to/disk.xml
Optionally, add the --persistent option to let Libvirt update the domain XML definition 'persistent'.
Finally, check inside the guest if the disk was indeed hotplug-inserted. The kernel should be triggered, as can be checked with dmesg:
[ 321.946440] virtio-pci 0000:00:06.0: using default PCI settings [...] [ 321.952782] vdb: vdb1 vdb2
In the above example I've added a disk as vdb with two partitions in the partition table.