この手順で仮想マシン上のRHEL5にディスクをホットプラグできる。
** RHEL6系は標準カーネルで対応しているのでこの手順は必要無し。
RHEL6系はホストマシンから
host# virsh attach-disk rhel6-vm /disk-file.img vdb
として仮想ディスクを追加すると、
guest# udevadm monitor
KERNEL[1347495382.970520] remove /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:0b (acpi) KERNEL[1347495382.970594] add /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:22 (acpi) UDEV [1347495382.970629] remove /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:0b (acpi) UDEV [1347495382.990487] add /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:22 (acpi) KERNEL[1347495383.039877] add /devices/pci0000:00/0000:00:09.0 (pci) UDEV [1347495383.048273] add /devices/pci0000:00/0000:00:09.0 (pci) KERNEL[1347495383.054381] add /devices/pci0000:00/0000:00:09.0/virtio5 (virtio) UDEV [1347495383.073997] add /devices/pci0000:00/0000:00:09.0/virtio5 (virtio) KERNEL[1347495383.074533] add /devices/virtual/bdi/252:16 (bdi) UDEV [1347495383.075088] add /devices/virtual/bdi/252:16 (bdi) KERNEL[1347495383.077906] add /devices/pci0000:00/0000:00:09.0/virtio5/block/vdb (block) UDEV [1347495383.104685] add /devices/pci0000:00/0000:00:09.0/virtio5/block/vdb (block)
このようにカーネル(udev)がイベントを取得でき、動的にデバイスの接続が可能。
同様に削除も可能、
host# virsh detach-disk rhel6-vm vdb
guest# udevadm monitor
KERNEL[1347495416.974120] remove /devices/virtual/bdi/252:16 (bdi) UDEV [1347495416.975045] remove /devices/virtual/bdi/252:16 (bdi) KERNEL[1347495416.975760] remove /devices/pci0000:00/0000:00:09.0/virtio5/block/vdb (block) UDEV [1347495416.977335] remove /devices/pci0000:00/0000:00:09.0/virtio5/block/vdb (block) KERNEL[1347495416.979012] remove /devices/pci0000:00/0000:00:09.0/virtio5 (virtio) UDEV [1347495416.979855] remove /devices/pci0000:00/0000:00:09.0/virtio5 (virtio) KERNEL[1347495416.982315] remove /devices/pci0000:00/0000:00:09.0 (pci) UDEV [1347495416.983299] remove /devices/pci0000:00/0000:00:09.0 (pci) KERNEL[1347495416.984000] remove /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:22 (acpi) UDEV [1347495416.985072] remove /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:22 (acpi)
しかしRHEL5系の場合、
host# virsh attach-disk rhel5-vm /disk-file.img vdb
標準でイベントを拾うことができない。
guest# udevmonitor
空
これはacpiphpモジュールをロードさせることでホットプラグが可能になる。
以下のファイルを作成して、起動時のロードされるように設定しておく。
guest# vim /etc/sysconfig/modules/acpiphp.modules
#!/bin/bash modprobe acpiphpguest# chmod +x /etc/sysconfig/modules/acpiphp.modules
再起動 or modprode acpiphp
guest# lsmod |grep acpiphp
acpiphp 58841 0
host# virsh attach-disk rhel5-vm /disk-file1.img vdb
host# virsh attach-disk rhel5-vm /disk-file2.img vdc
host# virsh attach-disk rhel5-vm /disk-file3.img vdd
UEVENT[1347501300.539658] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S8 UDEV [1347501300.539658] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S8 UEVENT[1347501300.571892] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S8 UEVENT[1347501300.590224] add@/devices/pci0000:00/0000:00:08.0 UEVENT[1347501300.607140] add@/devices/virtio-pci/virtio3 UEVENT[1347501300.625218] add@/block/vdb UEVENT[1347501300.633221] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S7 UEVENT[1347501300.653192] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S7 UEVENT[1347501300.683148] add@/devices/pci0000:00/0000:00:07.0 UEVENT[1347501300.708434] add@/devices/virtio-pci/virtio4 UEVENT[1347501300.719171] add@/block/vdc UEVENT[1347501300.719818] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S6 UEVENT[1347501300.720584] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S6 UEVENT[1347501300.730112] add@/devices/pci0000:00/0000:00:06.0 UEVENT[1347501300.730791] add@/devices/virtio-pci/virtio5 UEVENT[1347501300.731774] add@/block/vdd UDEV [1347501302.251070] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S7 UDEV [1347501302.691188] remove@/firmware/acpi/namespace/ACPI/_SB/PCI0/S6 UDEV [1347501304.566026] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S8 UDEV [1347501304.619257] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S7 UDEV [1347501304.868756] add@/firmware/acpi/namespace/ACPI/_SB/PCI0/S6 UDEV [1347501305.519140] add@/devices/pci0000:00/0000:00:08.0 UDEV [1347501307.512506] add@/devices/virtio-pci/virtio3 UDEV [1347501309.464859] add@/block/vdb UDEV [1347501311.182177] add@/devices/pci0000:00/0000:00:07.0 UDEV [1347501312.350176] add@/devices/virtio-pci/virtio4 UDEV [1347501312.976733] add@/block/vdc UDEV [1347501314.987497] add@/devices/pci0000:00/0000:00:06.0 UDEV [1347501316.405359] add@/devices/virtio-pci/virtio5 UDEV [1347501317.083238] add@/block/vdd
無事認識できました。
参考:http://www.linux-kvm.org/page/Hotadd_pci_devices
0 件のコメント:
コメントを投稿