--- source/detach-disk.xml | 233 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 229 insertions(+), 4 deletions(-) diff --git a/source/detach-disk.xml b/source/detach-disk.xml index 53f71e4..16d282c 100644 --- a/source/detach-disk.xml +++ b/source/detach-disk.xml @@ -9,16 +9,241 @@ </text> </description> - <options /> + <options> + <parameter requirement="required"> + <value type="string" requirement="required">domain</value> + <description> + The name of the domain from which a disk device is detached. + </description> + </parameter> + <parameter requirement="required"> + <keyword requirement="optional">--target</keyword> + <value type="string" requirement="required">target</value> + <description> + the disk device to be detached. "--target" itself is optional. + </description> + </parameter> + <parameter requirement="optional"> + <keyword requirement="required">--persistent</keyword> + <description> + with this option, the domain xml file is updated to remove the + element for the detached disk. + </description> + </parameter> + </options> <availability from="0.3.0" /> <notes /> - <examples type="usage" /> + <examples type="usage"> + <example> + <terminal>virsh # <bold>detach-disk</bold> <value>example-domain</value> <italic>--target</italic> <value>sdb</value></terminal> + <text> + Detaches <value>sdb</value> from <value>example-domain</value>. + </text> + </example> + </examples> - <examples type="fullcontext" /> - <reference type="seealso" /> + <examples type="fullcontext"> + <example> + <text> + We are running a domain which is defined as: + </text> + <terminal><domain type='kvm' id='2'> + <name>example-domain</name> + <uuid>6853c36f-af03-4968-a31d-1f3a9c3f699a</uuid> + <memory>1048576</memory> + <currentMemory>1048576</currentMemory> + <blkiotune> + <weight>800</weight> + </blkiotune> + <vcpu>2</vcpu> + <cputune> + <vcpupin vcpu='0' cpuset='1'/> + </cputune> + <os> + <type arch='x86_64' machine='pc-0.12'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/local/bin/qemu-system-x86_64</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw' cache='writeback'/> + <source file='/mnt/data/libvirt-images/vm2.img'/> + <target dev='vda' bus='virtio'/> + <alias name='virtio-disk0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2'/> + <source dev='/mnt/data/libvirt-images/example-vm.img'/> + <target dev='vdb' bus='virtio'/> + <alias name='virtio-disk1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> + </disk> + <controller type='ide' index='0'> + <alias name='ide0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <interface type='network'> + <mac address='52:54:00:9a:88:73'/> + <source network='default'/> + <target dev='vnet0'/> + <alias name='net0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <serial type='tcp'> + <source mode='bind' host='127.0.0.1' service='4555'/> + <protocol type='telnet'/> + <target port='0'/> + <alias name='serial0'/> + </serial> + <console type='tcp'> + <source mode='bind' host='127.0.0.1' service='4555'/> + <protocol type='telnet'/> + <target type='serial' port='0'/> + <alias name='serial0'/> + </console> + <input type='tablet' bus='usb'> + <alias name='input0'/> + </input> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='5900' autoport='yes'/> + <sound model='ac97'> + <alias name='sound0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </sound> + <video> + <model type='cirrus' vram='9216' heads='1'/> + <alias name='video0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <watchdog model='i6300esb' action='dump'> + <alias name='watchdog0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + </watchdog> + <memballoon model='virtio'> + <alias name='balloon0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </memballoon> + </devices> +</domain></terminal> + <text> + There are two disks defined: vda and vdb. + </text> + <terminal># fdisk -l + +Disk /dev/vdb doesn't contain a valid partition table + +Disk /dev/vda: 8589 MB, 8589934592 bytes +16 heads, 63 sectors/track, 16644 cylinders +Units = cylinders of 1008 * 512 = 516096 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disk identifier: 0x00057a9e + + Device Boot Start End Blocks Id System +/dev/vda1 * 3 15604 7863296 83 Linux +Partition 1 does not end on cylinder boundary. +/dev/vda2 15604 16645 524288 82 Linux swap / Solaris +Partition 2 does not end on cylinder boundary. + +Disk /dev/vdb: 8589 MB, 8589934592 bytes +16 heads, 63 sectors/track, 16644 cylinders +Units = cylinders of 1008 * 512 = 516096 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disk identifier: 0x00000000 + +# 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:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 20) +00:04.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) +00:05.0 SCSI storage controller: Red Hat, Inc Virtio block device +00:06.0 RAM memory: Red Hat, Inc Virtio memory balloon +00:07.0 System peripheral: Intel Corporation 6300ESB Watchdog Timer +00:08.0 SCSI storage controller: Red Hat, Inc Virtio block device </terminal> + <text> + To detach disk vdb, we run the command: + </text> + <terminal>virsh # detach-disk example-domain vdb +Disk detached successfully</terminal> + <text> + To verify that vdb is detached, we check it out from guest OS: + </text> + <terminal># fdisk -l + +Disk /dev/vda: 8589 MB, 8589934592 bytes +16 heads, 63 sectors/track, 16644 cylinders +Units = cylinders of 1008 * 512 = 516096 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disk identifier: 0x00057a9e + + Device Boot Start End Blocks Id System +/dev/vda1 * 3 15604 7863296 83 Linux +Partition 1 does not end on cylinder boundary. +/dev/vda2 15604 16645 524288 82 Linux swap / Solaris +Partition 2 does not end on cylinder boundary. + +# 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:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 20) +00:04.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) +00:06.0 RAM memory: Red Hat, Inc Virtio memory balloon +00:07.0 System peripheral: Intel Corporation 6300ESB Watchdog Timer +00:08.0 SCSI storage controller: Red Hat, Inc Virtio block device</terminal> + <text> + We can see that vdb and <italic>00:05.0 SCSI storage controller</italic> to which vdb was connected are gone. + </text> + </example> + </examples> + + <reference type="seealso"> + <item> + <link type="internal" href="attach-disk" /> + <name>attach-disk</name> + <description> + attach a disk device to a domain + </description> + </item> + <item> + <link type="internal" href="attach-device" /> + <name>attach-device</name> + <description> + attach device from an XML file + </description> + </item> + <item> + <link type="internal" href="detach-device" /> + <name>detach-device</name> + <description> + detach device from an XML file + </description> + </item> + </reference> </command> -- 1.7.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list