How to add/remove a vdisk to/from a guest LDom dynamically
Introduction to Virtual Disks
virtual disk contains two components: the virtual disk itself as it appears in a domain guest, and the virtual disk backend, which is where data is stored and where virtual I/O ends up. The virtual disk backend is exported from a service domain by the virtual disk server (vds) driver. The vds driver communicates with the virtual disk client (vdc) driver in the guest domain through the hypervisor using a logical domain channel (LDC). Finally, a virtual disk appears as /dev/[r]dsk/cXdYsZ devices in the guest domain.
Prerequisite Service
Before you proceed to add or remove the Vdisks dynamically to the Guest domains, please make sure the SMF service svc:/platform/sun4v/drd must be online in Guest LDom
Guest LDom# svcs drd
STATE STIME FMRI
online Aug_07 svc:/platform/sun4v/drd:default
If the service not online, you will receive the following errors when you try to add the disk devices to guest domains
pdom# ldm add-vdisk zvol4 zvol4@primary-vds0 g003
Guest LDom returned the following reason for failing the operation:
Cannot communicate with reconfiguration daemon (drd) in target domain.
drd SMF service may not be enabled.LDom g003 did not respond to request to configure VIO device
Verifying existing vdisks
Check/verify vdisks on Guest LDom
guest# format -e < /dev/null
Searching for disks…done AVAILABLE DISK SELECTIONS:
0. c0d0 <SUN-DiskImage-20GB cyl 566 alt 2 hd 96 sec 768>
/virtual-devices@100/channel-devices@200/disk@0
Specify disk (enter its number):
Check/verify vdisks on primary domain for a certain Guest LDom
primary# ldm list -o disk ldg1
NAME
ldg1 DISK NAME VOLUME TOUT ID DEVICE SERVER MPGROUP
vdisk1 vol1@primary-vds0 0 disk@0 primary
Adding a vdisk to a Guest LDom
Adding ZVOL storage as vdisk
primary# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
ldom 86.5G 14.6G 71.9G 16% 1.00x ONLINE –
rpool 136G 20.5G 115G 15% 1.00x ONLINE – primary# zfs create -V 5G ldom/disk2
primary# ldm add-vdsdev /dev/zvol/dsk/ldom/disk2 disk2@primary-vds0
primary# ldm add-vdisk disk2 disk2@primary-vds0 ldg1
Adding a file on UFS storage as Vdisk
primary# mkfile 5g /ldom/disk2
primary# ldm add-vdsdev /ldom/disk2 disk2@primary-vds0
primary# ldm add-vdisk disk2 disk2@primary-vds0 ldg1
Adding a whole disk as vdisk
primary# ldm add-vdsdev /dev/dsk/c1t0d0s2 disk2G@primary-vds0
primary# ldm add-vdisk disk2 disk2@primary-vds0 ldg1
Verification vdisk addition
Verifying the Disk addition from Primary Domain
primary# ldm list -o disk ldg1
NAME
ldg1 DISK NAME VOLUME TOUT ID DEVICE SERVER MPGROUP vdisk1 vol1@primary-vds0 0 disk@0 primary
disk2 disk2@primary-vds0 1 disk@1 primary
Verify success of previous commands on Guest LDom
guest# devfsadm -v
guest# format
Searching for disks…doneAVAILABLE DISK SELECTIONS:
0. c0d0 <SUN-DiskImage-20GB cyl 566 alt 2 hd 96 sec 768>
/virtual-devices@100/channel-devices@200/disk@0
1. c0d1 <SUN-DiskImage-5GB cyl 17474 alt 2 hd 1 sec 600>
/virtual-devices@100/channel-devices@200/disk@1
Specify disk (enter its number):
Removing vdisks dynamically from a Guest Domain
Vdisks can be removed dynamically from a Guest LDom as long as the device is not busy on Guest LDom
Successful removal of a vdisk from Guest LDom:
primary# ldm rm-vdisk disk2 ldg1
Failing attempt to remove a vdisk from Guest LDom in case the vdisk is busy or mounted:
# ldm rm-vdisk disk2 ldg1
Guest LDom returned the following reason for failing the operation: Resource Information
—————- ————————-
/dev/dsk/c0d1s0 mounted filesystem “/mnt”VIO operation failed because device is being used in LDom ldg1
Failed to remove vdisk instance