[libvirt] [PATCH 1/2] Support for 'hostonly' and 'internal' network in VirtualBox
Daniel P. Berrange
berrange at redhat.com
Wed May 6 09:49:20 UTC 2009
On Wed, Apr 29, 2009 at 01:14:15PM +0200, Pritesh Kothari wrote:
> Hi All,
>
> I have added the support for hostonly and internal network as suggested on irc
> and list and am attaching the patch for same.
>
> PATCH 1/2: contains changes in the xml parsing/formatting on libvirt side
> namely adding a mode attribute to <source> tag in domain/interface xml
> PATCH 2/2: contains changes in the vbox driver itself.
This patch isn't right - we shouldn't be adding more attributes for the
type=network config here, since its config is intended to be encapsulated
in the virNetwork XML.
That said, as per my comment in the other patch, I think we should go back
to your original proposal for adding a new type=internal in the <interface>
config, and leave the virNetwork APIs just for the host-only network
setup / config, so this patch would be redundant anyway
Regards,
Daniel
> commit 11024ae0d14c1d0a2fdf1d141ce598e14435b2d3
> Author: Pritesh Kothari <Pritesh.Kothari at Sun.com>
> Date: Wed Apr 29 10:49:02 2009 +0200
>
> added 'mode' attribute to source tag under interface
>
> diff --git a/src/domain_conf.c b/src/domain_conf.c
> index dde4020..bb134c0 100644
> --- a/src/domain_conf.c
> +++ b/src/domain_conf.c
> @@ -303,6 +303,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
>
> case VIR_DOMAIN_NET_TYPE_NETWORK:
> VIR_FREE(def->data.network.name);
> + VIR_FREE(def->data.network.mode);
> break;
>
> case VIR_DOMAIN_NET_TYPE_BRIDGE:
> @@ -880,6 +881,7 @@ virDomainNetDefParseXML(virConnectPtr conn,
> char *macaddr = NULL;
> char *type = NULL;
> char *network = NULL;
> + char *networkmode = NULL;
> char *bridge = NULL;
> char *dev = NULL;
> char *ifname = NULL;
> @@ -914,6 +916,7 @@ virDomainNetDefParseXML(virConnectPtr conn,
> (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
> (xmlStrEqual(cur->name, BAD_CAST "source"))) {
> network = virXMLPropString(cur, "network");
> + networkmode = virXMLPropString(cur, "mode");
> } else if ((network == NULL) &&
> (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
> (xmlStrEqual(cur->name, BAD_CAST "source"))) {
> @@ -961,13 +964,15 @@ virDomainNetDefParseXML(virConnectPtr conn,
>
> switch (def->type) {
> case VIR_DOMAIN_NET_TYPE_NETWORK:
> - if (network == NULL) {
> + if ((network == NULL) || (networkmode == NULL)) {
> virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
> - _("No <source> 'network' attribute specified with <interface type='network'/>"));
> + _("No <source> 'network' or 'mode' attribute specified with <interface type='network'/>"));
> goto error;
> }
> def->data.network.name = network;
> + def->data.network.mode = networkmode;
> network = NULL;
> + networkmode = NULL;
> break;
>
> case VIR_DOMAIN_NET_TYPE_ETHERNET:
> @@ -3011,8 +3016,9 @@ virDomainNetDefFormat(virConnectPtr conn,
>
> switch (def->type) {
> case VIR_DOMAIN_NET_TYPE_NETWORK:
> - virBufferEscapeString(buf, " <source network='%s'/>\n",
> - def->data.network.name);
> + virBufferVSprintf(buf, " <source network='%s' mode='%s'/>\n",
> + def->data.network.name,
> + def->data.network.mode);
> break;
>
> case VIR_DOMAIN_NET_TYPE_ETHERNET:
> diff --git a/src/domain_conf.h b/src/domain_conf.h
> index d4e7442..5fbc395 100644
> --- a/src/domain_conf.h
> +++ b/src/domain_conf.h
> @@ -162,6 +162,7 @@ struct _virDomainNetDef {
> } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
> struct {
> char *name;
> + char *mode;
> } network;
> struct {
> char *brname;
> --
> Libvir-list mailing list
> Libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
|: 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 :|
More information about the libvir-list
mailing list