[libvirt] [PATCH 0/2] Xen: Add support for interface model='netfront'

Xen HVM guests with PV drivers end up with two network interfaces for each configured interface. One of them being emulated by qemu and the other one paravirtual. As this might not be desirable, the attached patch provides a way for users to specify that only paravirtual network interface should be presented to the guest. The configuration was inspired by qemu/kvm driver, for which users can specify model='virtio' to use paravirtual network interface. The patch adds support for model='netfront' which results in type=netfront instead of type=ioemu (or nothing for newer xen versions) in guests native configuration. Xen's qemu ignores interfaces with type != ioemu and only paravirtual network device will be seen in the guest. Four possible configuration scenarios follow: - no model specified in domain's XML - libvirt will behave like before this change; it will set type=ioemu for HVM guests on xen host which is not newer than XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU - covered by existing tests - PV guest, any model - no functional change, model is passed as is (and ignored by the hypervisor) - covered by existing tests (e.g., *-net-e1000.*) - HVM guest, model=netfront - type is set to "netfront", model is not specified - covered by new *-net-netfront.* tests - HVM guest, model != netfront - type is set to "ioemu", model is passed as is - covered by new *-net-ioemu.* tests The fourth scenario feels like a regression for xen newer than XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU as users who had a model specified in their guest's configuration won't see a paravirtual interface in their guests any more. On the other hand, the reason for specifying a model is most likely the fact that they want to use such model which implies emulated interface. Users of older xen won't be affected at all as their xen provides paravirtual interface regardless of the type used. In previous version of this patch, I used "xenpv" instead of "netfront" as it looked more like kvm/qemu's virtio. However, you can find several tips how to force PV network interface for HVM guest by using type="netfront" so I changed it to conform with those tips. It also matches guest's driver name used for that device. Jiri Denemark (2): Support for interface model='netfront' Tests for interface type/model configuration src/xen/xend_internal.c | 32 +++++++++++---- src/xen/xm_internal.c | 38 +++++++++++++++-- tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr | 1 + tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 42 +++++++++++++++++++ .../sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr | 1 + tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 42 +++++++++++++++++++ tests/sexpr2xmltest.c | 3 + tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 25 +++++++++++ tests/xmconfigdata/test-fullvirt-net-ioemu.xml | 43 ++++++++++++++++++++ tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 25 +++++++++++ tests/xmconfigdata/test-fullvirt-net-netfront.xml | 43 ++++++++++++++++++++ tests/xmconfigtest.c | 3 + tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr | 1 + tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml | 31 ++++++++++++++ .../xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr | 1 + tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml | 31 ++++++++++++++ tests/xml2sexprtest.c | 3 + 17 files changed, 352 insertions(+), 13 deletions(-) create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.xml create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.cfg create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/xen/xend_internal.c | 32 ++++++++++++++++++++++++-------- src/xen/xm_internal.c | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 4d9dcd1..603ff6c 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1770,11 +1770,12 @@ xenDaemonParseSxprNets(virConnectPtr conn, for (cur = root; cur->kind == SEXPR_CONS; cur = cur->u.s.cdr) { node = cur->u.s.car; if (sexpr_lookup(node, "device/vif")) { - const char *tmp2, *model; + const char *tmp2, *model, *type; char buf[50]; tmp2 = sexpr_node(node, "device/vif/script"); tmp = sexpr_node(node, "device/vif/bridge"); model = sexpr_node(node, "device/vif/model"); + type = sexpr_node(node, "device/vif/type"); if (VIR_ALLOC(net) < 0) goto no_memory; @@ -1841,6 +1842,11 @@ xenDaemonParseSxprNets(virConnectPtr conn, !(net->model = strdup(model))) goto no_memory; + if (!model && type && + STREQ(type, "netfront") && + !(net->model = strdup("netfront"))) + goto no_memory; + if (VIR_REALLOC_N(def->nets, def->nnets + 1) < 0) goto no_memory; @@ -5500,15 +5506,25 @@ xenDaemonFormatSxprNet(virConnectPtr conn, !STRPREFIX(def->ifname, "vif")) virBufferVSprintf(buf, "(vifname '%s')", def->ifname); - if (def->model != NULL) + if (!hvm) { + if (def->model != NULL) + virBufferVSprintf(buf, "(model '%s')", def->model); + } + else if (def->model == NULL) { + /* + * apparently (type ioemu) breaks paravirt drivers on HVM so skip + * this from XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU + */ + if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) + virBufferAddLit(buf, "(type ioemu)"); + } + else if (STREQ(def->model, "netfront")) { + virBufferAddLit(buf, "(type netfront)"); + } + else { virBufferVSprintf(buf, "(model '%s')", def->model); - - /* - * apparently (type ioemu) breaks paravirt drivers on HVM so skip this - * from Xen 3.1.0 - */ - if (hvm && xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) virBufferAddLit(buf, "(type ioemu)"); + } if (!isAttach) virBufferAddLit(buf, ")"); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 40c1996..6c60839 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1020,6 +1020,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { while (list) { char script[PATH_MAX]; char model[10]; + char type[10]; char ip[16]; char mac[18]; char bridge[50]; @@ -1031,6 +1032,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { script[0] = '\0'; ip[0] = '\0'; model[0] = '\0'; + type[0] = '\0'; vifname[0] = '\0'; if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) @@ -1076,6 +1078,13 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { _("Model %s too big for destination"), data); goto skipnic; } + } else if (STRPREFIX(key, "type=")) { + int len = nextkey ? (nextkey - data) : sizeof(type) - 1; + if (virStrncpy(type, data, len, sizeof(type)) == NULL) { + xenXMError(conn, VIR_ERR_INTERNAL_ERROR, + _("Type %s too big for destination"), data); + goto skipnic; + } } else if (STRPREFIX(key, "vifname=")) { int len = nextkey ? (nextkey - data) : sizeof(vifname) - 1; if (virStrncpy(vifname, data, len, sizeof(vifname)) == NULL) { @@ -1145,10 +1154,16 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { !(net->data.ethernet.ipaddr = strdup(ip))) goto no_memory; } + if (model[0] && !(net->model = strdup(model))) goto no_memory; + if (!model[0] && type[0] && + STREQ(type, "netfront") && + !(net->model = strdup("netfront"))) + goto no_memory; + if (vifname[0] && !(net->ifname = strdup(vifname))) goto no_memory; @@ -2092,12 +2107,25 @@ static int xenXMDomainConfigFormatNet(virConnectPtr conn, goto cleanup; } - if (hvm && priv->xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) + if (!hvm) { + if (net->model != NULL) + virBufferVSprintf(&buf, ",model=%s", net->model); + } + else if (net->model == NULL) { + /* + * apparently type ioemu breaks paravirt drivers on HVM so skip this + * from XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU + */ + if (priv->xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) + virBufferAddLit(&buf, ",type=ioemu"); + } + else if (STREQ(net->model, "netfront")) { + virBufferAddLit(&buf, ",type=netfront"); + } + else { + virBufferVSprintf(&buf, ",model=%s", net->model); virBufferAddLit(&buf, ",type=ioemu"); - - if (net->model) - virBufferVSprintf(&buf, ",model=%s", - net->model); + } if (net->ifname) virBufferVSprintf(&buf, ",vifname=%s", -- 1.6.5.3

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr | 1 + tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 42 +++++++++++++++++++ .../sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr | 1 + tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 42 +++++++++++++++++++ tests/sexpr2xmltest.c | 3 + tests/xmconfigdata/test-fullvirt-net-ioemu.cfg | 25 +++++++++++ tests/xmconfigdata/test-fullvirt-net-ioemu.xml | 43 ++++++++++++++++++++ tests/xmconfigdata/test-fullvirt-net-netfront.cfg | 25 +++++++++++ tests/xmconfigdata/test-fullvirt-net-netfront.xml | 43 ++++++++++++++++++++ tests/xmconfigtest.c | 3 + tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr | 1 + tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml | 31 ++++++++++++++ .../xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr | 1 + tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml | 31 ++++++++++++++ tests/xml2sexprtest.c | 3 + 15 files changed, 295 insertions(+), 0 deletions(-) create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg create mode 100644 tests/xmconfigdata/test-fullvirt-net-ioemu.xml create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.cfg create mode 100644 tests/xmconfigdata/test-fullvirt-net-netfront.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr new file mode 100644 index 0000000..47ff828 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.sexpr @@ -0,0 +1 @@ +(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(cdrom '/root/boot.iso')(acpi 1)(vnc 1)(keymap ja)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(model 'e1000')(type 'ioemu')))) diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml new file mode 100644 index 0000000..4dc218f --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml @@ -0,0 +1,42 @@ +<domain type='xen' id='3'> + <name>fvtest</name> + <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid> + <memory>409600</memory> + <currentMemory>409600</currentMemory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <features> + <acpi/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> + <disk type='file' device='disk'> + <driver name='file'/> + <source file='/root/foo.img'/> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='file'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:1b:b1:47'/> + <source bridge='xenbr0'/> + <script path='vif-bridge'/> + <target dev='vif3.0'/> + <model type='e1000'/> + </interface> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='5903' autoport='no' keymap='ja'/> + </devices> +</domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr new file mode 100644 index 0000000..eee2304 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.sexpr @@ -0,0 +1 @@ +(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(cdrom '/root/boot.iso')(acpi 1)(vnc 1)(keymap ja)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type 'netfront')))) diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml new file mode 100644 index 0000000..57b8d27 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml @@ -0,0 +1,42 @@ +<domain type='xen' id='3'> + <name>fvtest</name> + <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid> + <memory>409600</memory> + <currentMemory>409600</currentMemory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <features> + <acpi/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> + <disk type='file' device='disk'> + <driver name='file'/> + <source file='/root/foo.img'/> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='file'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:1b:b1:47'/> + <source bridge='xenbr0'/> + <script path='vif-bridge'/> + <target dev='vif3.0'/> + <model type='netfront'/> + </interface> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='5903' autoport='no' keymap='ja'/> + </devices> +</domain> diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 1196e23..381af66 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -168,6 +168,9 @@ mymain(int argc, char **argv) DO_TEST("fv-sound", "fv-sound", 1); DO_TEST("fv-sound-all", "fv-sound-all", 1); + DO_TEST("fv-net-ioemu", "fv-net-ioemu", 1); + DO_TEST("fv-net-netfront", "fv-net-netfront", 1); + virCapabilitiesFree(caps); return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg new file mode 100644 index 0000000..922450b --- /dev/null +++ b/tests/xmconfigdata/test-fullvirt-net-ioemu.cfg @@ -0,0 +1,25 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" +pae = 1 +acpi = 1 +apic = 1 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +device_model = "/usr/lib/xen/bin/qemu-dm" +sdl = 0 +vnc = 1 +vncunused = 1 +vnclisten = "127.0.0.1" +vncpasswd = "123poi" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] +parallel = "none" +serial = "none" diff --git a/tests/xmconfigdata/test-fullvirt-net-ioemu.xml b/tests/xmconfigdata/test-fullvirt-net-ioemu.xml new file mode 100644 index 0000000..4a52a45 --- /dev/null +++ b/tests/xmconfigdata/test-fullvirt-net-ioemu.xml @@ -0,0 +1,43 @@ +<domain type='xen'> + <name>XenGuest2</name> + <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid> + <memory>592896</memory> + <currentMemory>403456</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='xenfv'>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/lib/xen/bin/qemu-dm</emulator> + <disk type='block' device='disk'> + <driver name='phy'/> + <source dev='/dev/HostVG/XenGuest2'/> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='file'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:66:92:9c'/> + <source bridge='xenbr1'/> + <script path='vif-bridge'/> + <model type='e1000'/> + </interface> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> + </devices> +</domain> diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.cfg b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg new file mode 100644 index 0000000..d15f1f5 --- /dev/null +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.cfg @@ -0,0 +1,25 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" +pae = 1 +acpi = 1 +apic = 1 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +device_model = "/usr/lib/xen/bin/qemu-dm" +sdl = 0 +vnc = 1 +vncunused = 1 +vnclisten = "127.0.0.1" +vncpasswd = "123poi" +disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ] +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,type=netfront" ] +parallel = "none" +serial = "none" diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.xml b/tests/xmconfigdata/test-fullvirt-net-netfront.xml new file mode 100644 index 0000000..efaf5b4 --- /dev/null +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.xml @@ -0,0 +1,43 @@ +<domain type='xen'> + <name>XenGuest2</name> + <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid> + <memory>592896</memory> + <currentMemory>403456</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='xenfv'>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/lib/xen/bin/qemu-dm</emulator> + <disk type='block' device='disk'> + <driver name='phy'/> + <source dev='/dev/HostVG/XenGuest2'/> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='file'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:66:92:9c'/> + <source bridge='xenbr1'/> + <script path='vif-bridge'/> + <model type='netfront'/> + </interface> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> + </devices> +</domain> diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index f6aea5a..a80f1e5 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -230,6 +230,9 @@ mymain(int argc, char **argv) DO_TEST("fullvirt-sound", 2); + DO_TEST("fullvirt-net-ioemu", 2); + DO_TEST("fullvirt-net-netfront", 2); + DO_TEST("escape-paths", 2); DO_TEST("no-source-cdrom", 2); DO_TEST("pci-devs", 2); diff --git a/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr new file mode 100644 index 0000000..e9fd597 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr @@ -0,0 +1 @@ +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(model 'e1000')(type ioemu)))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml b/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml new file mode 100644 index 0000000..4cdd1e6 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.xml @@ -0,0 +1,31 @@ +<domain type='xen'> + <name>fvtest</name> + <uuid>b5d70dd275cdaca517769660b059d8bc</uuid> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <memory>409600</memory> + <vcpu>1</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <features> + <acpi/> + </features> + <devices> + <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> + <interface type='bridge'> + <source bridge='xenbr0'/> + <mac address='00:16:3e:1b:b1:47'/> + <script path='vif-bridge'/> + <model type='e1000'/> + </interface> + <disk type='file'> + <source file='/root/foo.img'/> + <target dev='ioemu:hda'/> + </disk> + <graphics type='vnc' port='5917' keymap='ja'/> + </devices> +</domain> diff --git a/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr new file mode 100644 index 0000000..c888592 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr @@ -0,0 +1 @@ +(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type netfront)))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml b/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml new file mode 100644 index 0000000..f278f1f --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-fv-net-netfront.xml @@ -0,0 +1,31 @@ +<domain type='xen'> + <name>fvtest</name> + <uuid>b5d70dd275cdaca517769660b059d8bc</uuid> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <memory>409600</memory> + <vcpu>1</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <features> + <acpi/> + </features> + <devices> + <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> + <interface type='bridge'> + <source bridge='xenbr0'/> + <mac address='00:16:3e:1b:b1:47'/> + <script path='vif-bridge'/> + <model type='netfront'/> + </interface> + <disk type='file'> + <source file='/root/foo.img'/> + <target dev='ioemu:hda'/> + </disk> + <graphics type='vnc' port='5917' keymap='ja'/> + </devices> +</domain> diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index d83b37c..df9e607 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -151,6 +151,9 @@ mymain(int argc, char **argv) DO_TEST("fv-sound", "fv-sound", "fvtest", 1); + DO_TEST("fv-net-ioemu", "fv-net-ioemu", "fvtest", 1); + DO_TEST("fv-net-netfront", "fv-net-netfront", "fvtest", 1); + virCapabilitiesFree(caps); return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); -- 1.6.5.3

On Fri, Nov 27, 2009 at 07:00:47PM +0100, Jiri Denemark wrote:
Xen HVM guests with PV drivers end up with two network interfaces for each configured interface. One of them being emulated by qemu and the other one paravirtual. As this might not be desirable, the attached patch provides a way for users to specify that only paravirtual network interface should be presented to the guest.
The configuration was inspired by qemu/kvm driver, for which users can specify model='virtio' to use paravirtual network interface.
The patch adds support for model='netfront' which results in type=netfront instead of type=ioemu (or nothing for newer xen versions) in guests native configuration. Xen's qemu ignores interfaces with type != ioemu and only paravirtual network device will be seen in the guest.
ACK, to both these patches. 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 :|

On Fri, Nov 27, 2009 at 07:00:47PM +0100, Jiri Denemark wrote:
Xen HVM guests with PV drivers end up with two network interfaces for each configured interface. One of them being emulated by qemu and the other one paravirtual. As this might not be desirable, the attached patch provides a way for users to specify that only paravirtual network interface should be presented to the guest.
The configuration was inspired by qemu/kvm driver, for which users can specify model='virtio' to use paravirtual network interface.
The patch adds support for model='netfront' which results in type=netfront instead of type=ioemu (or nothing for newer xen versions) in guests native configuration. Xen's qemu ignores interfaces with type != ioemu and only paravirtual network device will be seen in the guest.
Four possible configuration scenarios follow:
- no model specified in domain's XML - libvirt will behave like before this change; it will set type=ioemu for HVM guests on xen host which is not newer than XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU - covered by existing tests
- PV guest, any model - no functional change, model is passed as is (and ignored by the hypervisor) - covered by existing tests (e.g., *-net-e1000.*)
- HVM guest, model=netfront - type is set to "netfront", model is not specified - covered by new *-net-netfront.* tests
- HVM guest, model != netfront - type is set to "ioemu", model is passed as is - covered by new *-net-ioemu.* tests
The fourth scenario feels like a regression for xen newer than XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU as users who had a model specified in their guest's configuration won't see a paravirtual interface in their guests any more. On the other hand, the reason for specifying a model is most likely the fact that they want to use such model which implies emulated interface. Users of older xen won't be affected at all as their xen provides paravirtual interface regardless of the type used.
In previous version of this patch, I used "xenpv" instead of "netfront" as it looked more like kvm/qemu's virtio. However, you can find several tips how to force PV network interface for HVM guest by using type="netfront" so I changed it to conform with those tips. It also matches guest's driver name used for that device.
Jiri Denemark (2): Support for interface model='netfront' Tests for interface type/model configuration
Thanks for the thorough explanations, I pushed both patches ! 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/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jiri Denemark