joyent/smartos-live — Issue #50: ZFS dataset for VMs are not removed when destroying a running VM
Author: Tenzer
Created: 2012-01-24 16:16:09+00:00
State: open

**Note, this may be because I have Node 0.6.8 on this machine, instead of the stock 0.4.9, and thereby hit an error such as #46.**

In this example I use `vmadm destroy` on a running VM, and the ZFS dataset is left behind:

[root@00-25-90-21-aa-c8 ~]# echo '{"brand":"kvm", "disks":[{"model":"virtio", "size":10240}]}' | vmadm create
Successfully created 4c359459-8887-415f-83d4-c38e21322182
[root@00-25-90-21-aa-c8 ~]# vmadm list
UUID TYPE RAM STATE ALIAS
4c359459-8887-415f-83d4-c38e21322182 KVM 256 running -
[root@00-25-90-21-aa-c8 ~]# vmadm destroy 4c359459-8887-415f-83d4-c38e21322182
Successfully deleted 4c359459-8887-415f-83d4-c38e21322182
[root@00-25-90-21-aa-c8 ~]# zfs list zones/4c359459-8887-415f-83d4-c38e21322182
NAME USED AVAIL REFER MOUNTPOINT
zones/4c359459-8887-415f-83d4-c38e21322182 31K 10.0G 31K /zones/4c359459-8887-415f-83d4-c38e21322182

And here the ZFS dataset is removed because the VM is stopped first:

[root@00-25-90-21-aa-c8 ~]# echo '{"brand":"kvm", "disks":[{"model":"virtio", "size":10240}]}' | vmadm create
Successfully created 6eefef94-d54f-46a1-8001-d43659f0a9b8
[root@00-25-90-21-aa-c8 ~]# vmadm stop -f 6eefef94-d54f-46a1-8001-d43659f0a9b8
Succesfully completed stop for 6eefef94-d54f-46a1-8001-d43659f0a9b8
[root@00-25-90-21-aa-c8 ~]# vmadm destroy 6eefef94-d54f-46a1-8001-d43659f0a9b8
Successfully deleted 6eefef94-d54f-46a1-8001-d43659f0a9b8
[root@00-25-90-21-aa-c8 ~]# zfs list zones/6eefef94-d54f-46a1-8001-d43659f0a9b8
cannot open 'zones/6eefef94-d54f-46a1-8001-d43659f0a9b8': dataset does not exist

Is this something you already have fixed, or should I try to debug and fix it? :)

(Looking at the output above, I can see there is a typo in the output for the stop command, do you want me to create a separate issue for that?)