[libvirt] [PATCH v2] macvtap: libvirtd forgot macvtap device name during a shutdown/restart cycle

V2: - removed change from virDomainNetDefFormat. The reported problem also does not occur. During a shutdown/restart cycle libvirtd forgot the macvtap device name that it had created on behalf of a VM so that a stale macvtap device remained on the host when the VM terminated. Libvirtd has to actively tear down a macvtap device and it uses its name for identifying which device to tear down. The solution is to not blank out the <target dev='...'/> completely, but only blank it out on VMs that are not active. So, if a VM is active, the device name makes it into the XML and is also being parsed. If a VM is not active, the device name is discarded. Signed-off-by: Stefan Berger <stefanb@us.ibm.com> --- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: libvirt-acl/src/conf/domain_conf.c =================================================================== --- libvirt-acl.orig/src/conf/domain_conf.c +++ libvirt-acl/src/conf/domain_conf.c @@ -2343,7 +2343,8 @@ virDomainNetDefParseXML(virCapsPtr caps, def->data.direct.linkdev = dev; dev = NULL; - VIR_FREE(ifname); + if ((flags & VIR_DOMAIN_XML_INACTIVE)) + VIR_FREE(ifname); break;

On Tue, Nov 02, 2010 at 07:14:19PM -0400, Stefan Berger wrote:
V2: - removed change from virDomainNetDefFormat. The reported problem also does not occur.
During a shutdown/restart cycle libvirtd forgot the macvtap device name that it had created on behalf of a VM so that a stale macvtap device remained on the host when the VM terminated. Libvirtd has to actively tear down a macvtap device and it uses its name for identifying which device to tear down.
The solution is to not blank out the <target dev='...'/> completely, but only blank it out on VMs that are not active. So, if a VM is active, the device name makes it into the XML and is also being parsed. If a VM is not active, the device name is discarded.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
--- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Index: libvirt-acl/src/conf/domain_conf.c =================================================================== --- libvirt-acl.orig/src/conf/domain_conf.c +++ libvirt-acl/src/conf/domain_conf.c @@ -2343,7 +2343,8 @@ virDomainNetDefParseXML(virCapsPtr caps, def->data.direct.linkdev = dev; dev = NULL;
- VIR_FREE(ifname); + if ((flags & VIR_DOMAIN_XML_INACTIVE)) + VIR_FREE(ifname);
break;
Looks fine to me now, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 11/03/2010 05:13 AM, Daniel Veillard wrote:
On Tue, Nov 02, 2010 at 07:14:19PM -0400, Stefan Berger wrote:
V2: - removed change from virDomainNetDefFormat. The reported problem also does not occur.
During a shutdown/restart cycle libvirtd forgot the macvtap device name that it had created on behalf of a VM so that a stale macvtap device remained on the host when the VM terminated. Libvirtd has to actively tear down a macvtap device and it uses its name for identifying which device to tear down.
The solution is to not blank out the<target dev='...'/> completely, but only blank it out on VMs that are not active. So, if a VM is active, the device name makes it into the XML and is also being parsed. If a VM is not active, the device name is discarded.
Signed-off-by: Stefan Berger<stefanb@us.ibm.com>
--- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Index: libvirt-acl/src/conf/domain_conf.c =================================================================== --- libvirt-acl.orig/src/conf/domain_conf.c +++ libvirt-acl/src/conf/domain_conf.c @@ -2343,7 +2343,8 @@ virDomainNetDefParseXML(virCapsPtr caps, def->data.direct.linkdev = dev; dev = NULL;
- VIR_FREE(ifname); + if ((flags& VIR_DOMAIN_XML_INACTIVE)) + VIR_FREE(ifname);
break;
Looks fine to me now,
ACK, Pushed.
Thanks Stefan
Daniel
participants (2)
-
Daniel Veillard
-
Stefan Berger