On Mon, Jul 20, 2009 at 12:51:18PM +0100, Mark McLoughlin wrote: > Currently, an interface's vlan number corresponds to its index in > the table of network interfaces. That is no longer true when we > allow devices to be removed. > > To fix this, we store the vlan number in the domain's state XML > so that it survives libvirtd restarts. > > * src/domain_conf.h: add vlan number to virDomainNetDef > > * src/domain_conf.c: store it in XML as <state vlan='N'/>, defaulting > to -1 if this is state saved by a previous version of libvirt > > * src/qemu_conf.c: assign vlan numbers before starting qemu Am I right in thinking we only need to preserve this info so that we can figure out the next free VLAN number for hot-plug ? > --- > src/domain_conf.c | 12 ++++++++++++ > src/domain_conf.h | 1 + > src/qemu_conf.c | 7 +++++-- > 3 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/src/domain_conf.c b/src/domain_conf.c > index 2b4fe90..cce863c 100644 > --- a/src/domain_conf.c > +++ b/src/domain_conf.c > @@ -954,6 +954,7 @@ virDomainNetDefParseXML(virConnectPtr conn, > char *internal = NULL; > char *nic_name = NULL; > char *hostnet_name = NULL; > + char *vlan = NULL; > > if (VIR_ALLOC(def) < 0) { > virReportOOMError(conn); > @@ -1023,6 +1024,7 @@ virDomainNetDefParseXML(virConnectPtr conn, > xmlStrEqual(cur->name, BAD_CAST "state")) { > nic_name = virXMLPropString(cur, "nic"); > hostnet_name = virXMLPropString(cur, "hostnet"); > + vlan = virXMLPropString(cur, "vlan"); > } > } > cur = cur->next; > @@ -1038,6 +1040,13 @@ virDomainNetDefParseXML(virConnectPtr conn, > def->hostnet_name = hostnet_name; > nic_name = hostnet_name = NULL; > > + def->vlan = -1; > + if (vlan && virStrToLong_i(vlan, NULL, 10, &def->vlan) < 0) { > + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", > + _("Cannot parse <state> 'vlan' attribute")); > + goto error; > + } I'm wondering if we shouldn't just add a virXMLPropInt() method which would mean we wouldn't have to keep doing the virStrToLong stuff throughout the XML parsing code. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list