The ephemeral flag helps support migration with PCI-passthrough.
An ephemeral hostdev is automatically unplugged before migration
and replugged (if one is available on the destination) after
migration.
---
docs/schemas/network.rng | 8 ++++++++
src/conf/network_conf.c | 11 +++++++++++
src/conf/network_conf.h | 1 +
tests/networkxml2xmlin/hostdev-pf.xml | 2 +-
tests/networkxml2xmlin/hostdev.xml | 2 +-
tests/networkxml2xmlout/hostdev-pf.xml | 2 +-
tests/networkxml2xmlout/hostdev.xml | 2 +-
7 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 4abfd91..c86ade8 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -100,6 +100,14 @@
</choice>
</attribute>
</optional>
+ <optional>
+ <attribute name="ephemeral">
+ <choice>
+ <value>yes</value>
+ <value>no</value>
+ </choice>
+ </attribute>
+ </optional>
<interleave>
<choice>
<group>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 228951d..4f48f64 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1222,6 +1222,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
int nIps, nPortGroups, nForwardIfs, nForwardPfs, nForwardAddrs;
char *forwardDev = NULL;
char *forwardManaged = NULL;
+ char *forwardEphemeral = NULL;
char *type = NULL;
xmlNodePtr save = ctxt->node;
xmlNodePtr bandwidthNode = NULL;
@@ -1380,6 +1381,11 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if (STRCASEEQ(forwardManaged, "yes"))
def->managed = 1;
}
+ forwardEphemeral = virXPathString("string(./@ephemeral)", ctxt);
+ if (forwardEphemeral != NULL) {
+ if (STRCASEEQ(forwardEphemeral, "yes"))
+ def->ephemeral = 1;
+ }
/* all of these modes can use a pool of physical interfaces */
nForwardIfs = virXPathNodeSet("./interface", ctxt,
&forwardIfNodes);
@@ -1527,6 +1533,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
VIR_FREE(type);
VIR_FREE(forwardDev);
VIR_FREE(forwardManaged);
+ VIR_FREE(forwardEphemeral);
VIR_FREE(forwardPfNodes);
VIR_FREE(forwardIfNodes);
VIR_FREE(forwardAddrNodes);
@@ -1861,6 +1868,10 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int
flags)
virBufferAddLit(&buf, " managed='yes'");
else
virBufferAddLit(&buf, " managed='no'");
+ if (def->ephemeral == 1)
+ virBufferAddLit(&buf, " ephemeral='yes'");
+ else
+ virBufferAddLit(&buf, " ephemeral='no'");
}
virBufferAsprintf(&buf, "%s>\n",
(def->nForwardIfs || def->nForwardPfs) ? "" :
"/");
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 3e46304..37a5d42 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -186,6 +186,7 @@ struct _virNetworkDef {
int forwardType; /* One of virNetworkForwardType constants */
int managed; /* managed attribute for hostdev mode */
+ int ephemeral; /* ephemeral attribute for hostdev mode */
/* If there are multiple forward devices (i.e. a pool of
* interfaces), they will be listed here.
diff --git a/tests/networkxml2xmlin/hostdev-pf.xml
b/tests/networkxml2xmlin/hostdev-pf.xml
index 7bf857d..6b928a6 100644
--- a/tests/networkxml2xmlin/hostdev-pf.xml
+++ b/tests/networkxml2xmlin/hostdev-pf.xml
@@ -1,7 +1,7 @@
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
- <forward mode='hostdev' managed='yes'>
+ <forward mode='hostdev' managed='yes' ephemeral='yes'>
<pf dev='eth2'/>
</forward>
</network>
diff --git a/tests/networkxml2xmlin/hostdev.xml b/tests/networkxml2xmlin/hostdev.xml
index 03f1411..406c2df 100644
--- a/tests/networkxml2xmlin/hostdev.xml
+++ b/tests/networkxml2xmlin/hostdev.xml
@@ -1,7 +1,7 @@
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
- <forward mode='hostdev' managed='yes'>
+ <forward mode='hostdev' managed='yes' ephemeral='yes'>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x1'/>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x2'/>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x3'/>
diff --git a/tests/networkxml2xmlout/hostdev-pf.xml
b/tests/networkxml2xmlout/hostdev-pf.xml
index 7bf857d..6b928a6 100644
--- a/tests/networkxml2xmlout/hostdev-pf.xml
+++ b/tests/networkxml2xmlout/hostdev-pf.xml
@@ -1,7 +1,7 @@
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
- <forward mode='hostdev' managed='yes'>
+ <forward mode='hostdev' managed='yes' ephemeral='yes'>
<pf dev='eth2'/>
</forward>
</network>
diff --git a/tests/networkxml2xmlout/hostdev.xml b/tests/networkxml2xmlout/hostdev.xml
index 03f1411..406c2df 100644
--- a/tests/networkxml2xmlout/hostdev.xml
+++ b/tests/networkxml2xmlout/hostdev.xml
@@ -1,7 +1,7 @@
<network>
<name>hostdev</name>
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
- <forward mode='hostdev' managed='yes'>
+ <forward mode='hostdev' managed='yes' ephemeral='yes'>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x1'/>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x2'/>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x3'/>
--
1.7.4.4