提交 c374353c 编写于 作者: M Marek Marczykowski 提交者: Jim Fehlig

conf: support backend domain name in disk and network devices

At least Xen supports backend drivers in another domain (aka "driver
domain"). This patch introduces an XML config option for specifying the
backend domain name for <disk> and <interface> devices.  E.g.

  <disk>
    <backenddomain name='diskvm'/>
    ...
  </disk>
  <interface type='bridge'>
    <backenddomain name='netvm'/>
    ...
  </interface>

In the future, same option will be needed for USB devices (hostdev
objects), but for now libxl doesn't have support for PVUSB.
Signed-off-by: NMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
上级 8f8e581a
......@@ -2372,6 +2372,12 @@
</li>
</ul>
</dd>
<dt><code>backenddomain</code></dt>
<dd>The optional <code>backenddomain</code> element allows specifying a
backend domain (aka driver domain) hosting the disk. Use the
<code>name</code> attribute to specify the backend domain name.
<span class="since">Since 1.2.13 (Xen only)</span>
</dd>
<dt><code>boot</code></dt>
<dd>Specifies that the disk is bootable. The <code>order</code>
attribute determines the order in which devices will be tried during
......@@ -4256,6 +4262,29 @@ qemu-kvm -net nic,model=? /dev/null
network device.
<span class="since">Since 0.9.10 (QEMU and KVM only)</span>.
</p>
<h5><a name="elementDomain">Setting up a network backend in a driver domain</a></h5>
<pre>
...
&lt;devices&gt;
...
&lt;interface type='bridge'&gt;
&lt;source bridge='br0'/&gt;
<b>&lt;backenddomain name='netvm'/&gt;</b>
&lt;/interface&gt;
...
&lt;/devices&gt;
...</pre>
<p>
The optional <code>backenddomain</code> element allows specifying a
backend domain (aka driver domain) for the interface. Use the
<code>name</code> attribute to specify the backend domain name. You
can use it to create a direct network link between domains (so data
will not go through host system). Use with type 'ethernet' to create
plain network link, or with type 'bridge' to connect to a bridge inside
the backend domain.
<span class="since">Since 1.2.13 (Xen only)</span>
</p>
<h5><a name="elementQoS">Quality of service</a></h5>
......
......@@ -1173,6 +1173,14 @@
<optional>
<ref name="deviceBoot"/>
</optional>
<optional>
<element name="backenddomain">
<attribute name="name">
<ref name="domainName"/>
</attribute>
<empty/>
</element>
</optional>
<optional>
<element name="readonly">
<empty/>
......@@ -2371,6 +2379,14 @@
<empty/>
</element>
</optional>
<optional>
<element name="backenddomain">
<attribute name="name">
<ref name="domainName"/>
</attribute>
<empty/>
</element>
</optional>
<optional>
<element name="model">
<attribute name="type">
......
......@@ -1267,6 +1267,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->wwn);
VIR_FREE(def->vendor);
VIR_FREE(def->product);
VIR_FREE(def->domain_name);
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def);
......@@ -1449,6 +1450,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(def->backend.vhost);
VIR_FREE(def->virtPortProfile);
VIR_FREE(def->script);
VIR_FREE(def->domain_name);
VIR_FREE(def->ifname);
VIR_FREE(def->ifname_guest);
VIR_FREE(def->ifname_guest_actual);
......@@ -5887,6 +5889,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
char *discard = NULL;
char *mirrorFormat = NULL;
char *mirrorType = NULL;
char *domain_name = NULL;
int expected_secret_usage = -1;
int auth_secret_usage = -1;
int ret = 0;
......@@ -5952,6 +5955,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
if (target &&
STRPREFIX(target, "ioemu:"))
memmove(target, target+6, strlen(target)-5);
} else if (!domain_name &&
xmlStrEqual(cur->name, BAD_CAST "backenddomain")) {
domain_name = virXMLPropString(cur, "name");
} else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) {
if (virXPathUInt("string(./geometry/@cyls)",
ctxt, &def->geometry.cylinders) < 0) {
......@@ -6676,6 +6682,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
driverName = NULL;
def->src->encryption = encryption;
encryption = NULL;
def->domain_name = domain_name;
domain_name = NULL;
def->serial = serial;
serial = NULL;
def->wwn = wwn;
......@@ -6738,6 +6746,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_FREE(product);
VIR_FREE(mirrorType);
VIR_FREE(mirrorFormat);
VIR_FREE(domain_name);
ctxt->node = save_ctxt;
return def;
......@@ -7527,6 +7536,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
char *mode = NULL;
char *linkstate = NULL;
char *addrtype = NULL;
char *domain_name = NULL;
char *vhostuser_mode = NULL;
char *vhostuser_path = NULL;
char *vhostuser_type = NULL;
......@@ -7666,6 +7676,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
} else if (!script &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
script = virXMLPropString(cur, "path");
} else if (!domain_name &&
xmlStrEqual(cur->name, BAD_CAST "backenddomain")) {
domain_name = virXMLPropString(cur, "name");
} else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
model = virXMLPropString(cur, "type");
} else if (xmlStrEqual(cur->name, BAD_CAST "driver")) {
......@@ -7965,6 +7978,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
def->script = script;
script = NULL;
}
if (domain_name != NULL) {
def->domain_name = domain_name;
domain_name = NULL;
}
if (ifname != NULL) {
def->ifname = ifname;
ifname = NULL;
......@@ -8234,6 +8251,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_FREE(mode);
VIR_FREE(linkstate);
VIR_FREE(addrtype);
VIR_FREE(domain_name);
VIR_FREE(trustGuestRxFilters);
VIR_FREE(ips);
VIR_FREE(vhost_path);
......@@ -17162,6 +17180,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
def->src->backingStoreRaw, 1) < 0)
return -1;
virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
virDomainDiskGeometryDefFormat(buf, def);
virDomainDiskBlockIoDefFormat(buf, def);
......@@ -18136,6 +18156,7 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, "<script path='%s'/>\n",
def->script);
virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
if (def->ifname &&
!((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
(STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) {
......
......@@ -700,6 +700,7 @@ struct _virDomainDiskDef {
int sgio; /* enum virDomainDeviceSGIO */
int discard; /* enum virDomainDiskDiscard */
unsigned int iothread; /* unused = 0, > 0 specific thread # */
char *domain_name; /* backend domain name */
};
......@@ -996,6 +997,7 @@ struct _virDomainNetDef {
unsigned long sndbuf;
} tune;
char *script;
char *domain_name; /* backend domain name */
char *ifname;
char *ifname_guest;
char *ifname_guest_actual;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册