[libvirt] adding bandwidth control support
by Max Zhen
My last post failed, resend...
Max Zhen at 2008-12-24 18:39 wrote:
> Hi,
>
> I'm working on adding bandwidth control support in
> virt-install/virsh/libvirt on Xen.
> This support can allow setting bandwidth control in dom0 (I'm working on
> Solaris dom0 now) for virtual nic devices used in a domU.
> I've attached my design in this email.
> Basically, this design is about how to represent bandwidth limit
> information in command line for virsh/virt-install and how to represent
> it in current XML configuration file for a domU.
>
> Your comments will be highly appreciated :).
>
> Thanks,
> Max
>
>
There are a few things to do to achieve this goal:
1. extend current command line syntax of 'virsh attach-interface'
2. extend current command line syntax of 'virt-install'
3. define bandwidth representation in XML format
For 1.
I will change the current command line syntax to:
virsh attach-interface <domain> <type> <source> [--target <target>]
[--mac <mac>] [--script <script>] [--rate <rate-string>]
So that we are able to specify bandwidth as "--rate 100M" in command line, like:
#virsh attach-interface domu bridge bge0 --rate 100M
In this case, bandwidth is specified as an integer with one of the scale
suffixes K, M, or G for Kbps, Mbps, or Gbps.
For 2.
I will add one more option "--rate=rate-string" to current option set of
virt-install command. Users can repeatedly add more than one 'rate' options
to set bandwidth for multiple nic devices respectively, if needed.
For example, with below command line, we start installing a domain with two
nic devices whose bandwidth are set to 100Mb/s and 200Mb/s respectively:
#virt-install -n snv105 -r 2048 -p --file=/root/snv105
--location=/solarisdvd.iso -b bge0 --rate=100M -b bge1 --rate=200M
In this case, bandwidth is specified as an integer with one of the scale
suffixes K, M, or G for Kbps, Mbps, or Gbps.
For 3.
All user specified bandwidth will be represented as part of interface
element currently defined in XML configuration file.
The new format looks like:
<interface type='bridge'>
<source bridge='e1000g1'/>
<flowcontrol>
<rate unit='megabit' period='second' value='100'/>
</flowcontrol>
</interface>
So, I create a new element, "flowcontrol", inside "interface" element. Inside
"flowcontrol", I provide bandwidth by setting "rate" element with three
attributes, "unit", "period" and "value" to express the bandwidth limit.
The supported unit can be 'gigabit', 'megabit' and 'kilobit'.
The supported period can be 'second', 'millisecond' and 'microsecond'.
And value is an integer to express the amount of data in unit allowed to be
transfered in period of time.
More elements can be added inside "flowcontrol" element, if we want to add more
flow control policies in the future.
15 years, 10 months
[libvirt] Adding VirtualBox support to libvirt
by Pritesh Kothari
Hi,
I am in the process of adding support for virtualbox in libvirt.
Basically Virtualbox exports its API through XPCOM. Now to simplify
things I was thinking of using C++ and already existing xpcom component
in virtualbox but since libvirt exports C API i am not sure if i should
use C++ or stick to plain C.
I would like to request the libvirt community for its comment
on this.
Regards,
Pritesh
15 years, 10 months
[libvirt] [PATCH ] (type ioem) adding qemu nic configuration option in to libvirt (XEN)
by Gihan Munasinghe
Guys
I have added a new attribute with with in <interface > tag called "qemu"
which can be either true or false..
Indicating if the user wants XEN to create qeum net device or not.. This
will fix the problem with PV net drivers with XEN..
Check the following examples
e.g 1) Interface tag with qemu attribute set to false
<interface type='bridge' qemu='false'>
<mac address='00:16:3e:00:a5:01'/>
<source bridge='eth0'/>
<target dev='vif1.0'/>
</interface>
qemu-dm output
---------------------
/usr/lib64/xen/bin/qemu-dm -d 60 -domain-name benchmark1 -k en-gb -vnc
0.0.0.0:1 -vcpus 2 -boot c -serial pty -acpi -usb -net none -M xenfv
XEND has configured the hvm guest not to have network card via qemu
e.g 2) Interface tag with qemu attribute set to true with qemu supported
nic model
<interface type='bridge' qemu='true'>
<mac address='00:16:3e:00:a5:01'/>
<source bridge='eth0'/>
<target dev='vif1.0'/>
<model type='e1000'/>
</interface>
qemu-dm output
---------------------
/usr/lib64/xen/bin/qemu-dm -d 61 -domain-name benchmark1 -k en-gb -vnc
0.0.0.0:1 -vcpus 2 -boot c -serial pty -acpi -usb -net
nic,vlan=1,macaddr=00:16:3e:00:a5:01,model=e1000 -net
tap,vlan=1,ifname=tap61.0,bridge=eth0 -M xenfv
Now XEND have configured the hvm guest to have emulated nic of the model
"e1000"
Therefore now, via libvirt configuration I have the ability ask xen to
either to configure qemu network card or not (when I have pv divers
installed with in my VM )
I have attached the patch files, Let me know what you guys think.
Thanks
Gihan
--
Gihan Munasinghe
R&D Team Leader
XCalibre Communications Ltd.
www.flexiscale.com
--- domain_conf.h.back 2008-12-04 15:31:38.000000000 +0000
+++ domain_conf.h 2008-12-04 20:28:16.000000000 +0000
@@ -127,9 +127,17 @@
VIR_DOMAIN_NET_TYPE_NETWORK,
VIR_DOMAIN_NET_TYPE_BRIDGE,
- VIR_DOMAIN_NET_TYPE_LAST,
+ VIR_DOMAIN_NET_TYPE_LAST
};
+/*Holds the values that can be passed as qemu attribute in <inteface >*/
+enum virDomainNetQemuAllocateType{
+ VIR_DOMAIN_NET_QEMU_ALLOC_TRUE,
+ VIR_DOMAIN_NET_QEMU_ALLOC_FALSE,
+
+ VIR_DOMAIN_NET_QEMU_ALLOC_LAST
+
+};
/* Stores the virtual network interface configuration */
typedef struct _virDomainNetDef virDomainNetDef;
@@ -156,6 +164,8 @@
} bridge;
} data;
char *ifname;
+ int qemu_allocate;/* This is set so that the users can ask xen not give vm's a network card
+ maily to with the (type none)/(type ieoum) tags wchi will be send to xend*/
};
enum virDomainChrSrcType {
@@ -608,5 +618,5 @@
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
-
+VIR_ENUM_DECL(virDomainNetQemuAllocate)
#endif /* __DOMAIN_CONF_H */
--- domain_conf.c.back 2008-12-04 15:31:40.000000000 +0000
+++ domain_conf.c 2008-12-04 20:30:31.000000000 +0000
@@ -142,6 +142,10 @@
"usb",
"pci")
+VIR_ENUM_IMPL(virDomainNetQemuAllocate, VIR_DOMAIN_NET_QEMU_ALLOC_LAST,
+ "true",
+ "false")
+
#define virDomainReportError(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
@@ -787,6 +791,7 @@
char *address = NULL;
char *port = NULL;
char *model = NULL;
+ char *qemu_alloc = NULL;
if (VIR_ALLOC(def) < 0) {
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
@@ -800,6 +805,17 @@
_("unknown interface type '%s'"), type);
goto error;
}
+ qemu_alloc = virXMLPropString(node, "qemu");
+ if( qemu_alloc!=NULL){
+ if ((def->qemu_allocate = virDomainNetQemuAllocateTypeFromString(qemu_alloc)) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unknown qemu alloc '%s'"), qemu_alloc);
+ goto error;
+ }
+
+ }else{
+ def->qemu_allocate = VIR_DOMAIN_NET_QEMU_ALLOC_TRUE; // by default the aloocation will be true
+ }
} else {
def->type = VIR_DOMAIN_NET_TYPE_USER;
}
@@ -818,6 +834,7 @@
(def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
(xmlStrEqual(cur->name, BAD_CAST "source"))) {
bridge = virXMLPropString(cur, "bridge");
+
} else if ((dev == NULL) &&
(def->type == VIR_DOMAIN_NET_TYPE_ETHERNET) &&
xmlStrEqual(cur->name, BAD_CAST "source")) {
--- xend_internal.c.back 2008-12-04 15:31:38.000000000 +0000
+++ xend_internal.c 2008-12-04 21:05:49.000000000 +0000
@@ -1773,10 +1773,9 @@
if (VIR_ALLOC(net) < 0)
goto no_memory;
- if ((tmp2 && strstr(tmp2, "bridge")) || tmp) {
- net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
- /* XXX virtual network reverse resolve */
-
+ if ((tmp2 && (strstr(tmp2, "bridge") )) || tmp) {
+ net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+ /* XXX virtual network reverse resolve */
if (tmp &&
!(net->data.bridge.brname = strdup(tmp)))
goto no_memory;
@@ -5153,10 +5152,15 @@
/*
* apparently (type ioemu) breaks paravirt drivers on HVM so skip this
- * from Xen 3.1.0
+ * from Xen 3.1.0 This happence as XEN try to allocate a network card via qemu
*/
- if ((hvm) && (xendConfigVersion < 4))
- virBufferAddLit(buf, "(type ioemu)");
+// if ((hvm) && (xendConfigVersion < 4) )
+ if ((hvm) && (def->qemu_allocate==VIR_DOMAIN_NET_QEMU_ALLOC_FALSE)){ /* If we have asked the qemu not to allocte a net work for hvm guest.
+ This way you would not have a problem with PV drivers on HVM guests*/
+ virBufferAddLit(buf, "(type none)");
+ }else {
+ virBufferAddLit(buf, "(type ioemu)");
+ }
if (!isAttach)
virBufferAddLit(buf, ")");
15 years, 10 months
[libvirt] adding tests....
by Jim Meyering
In adding a couple of tests, I noticed that libvirtd --config=no-such
didn't diagnose my mistake.
I fixed that with the first patch below:
diagnose "libvirtd --config=no-such-file"
* qemud/qemud.c (remoteReadConfigFile): Don't return 0 (success)
when the config file is unreadable or nonexistent
Return -1, not 0, upon virConfReadFile failure.
(main): If remote_config_file is not specified via --config(-f),
use the default config file only if it exists. Otherwise,
use /dev/null.
However, that made it so libvirtd gave two diagnostics:
Failed to open file 'no-such': No such file or directory
libvir: Config error : failed to open no-such for reading
The latter part of that patch fixes it like this:
* src/conf.c (virConfReadFile): Don't diagnose virFileReadAll
failure, since it already does that.
Finally, I went to add the two tests,
one to ensure libvirtd --config=no-such-file now fails, as I expected
another to start libvirtd and then run a small pool-related test via
a separate virsh invocation.
But that made me see a bug in tests/Makefile.am:
A missing backslash made it so the virsh-all test wasn't being run.
Easy to fix. But then, I saw when virsh-all runs it generated too
much output, so I did this:
tests: quiet virsh-all
* tests/virsh-all: For now, ignore diagnostics and exit status,
when running all virsh commands.
Finally, here are the two tests:
add tests
* tests/libvirtd-pool: New file.
* tests/libvirtd-fail: New file.
* tests/Makefile.am (test_scripts): Add omitted backslash,
so that the virsh-all test is run.
Add libvirtd-fail and libvirtd-pool.
>From aaea6d51f5200e58086d9cabf8b6e7fac7c460f8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 8 Jan 2009 20:17:35 +0100
Subject: [PATCH 1/3] diagnose "libvirtd --config=no-such-file"
* qemud/qemud.c (remoteReadConfigFile): Don't return 0 (success)
when the config file is unreadable or nonexistent
Return -1, not 0, upon virConfReadFile failure.
(main): If remote_config_file is not specified via --config(-f),
use the default config file only if it exists. Otherwise,
use /dev/null.
* src/conf.c (virConfReadFile): Don't diagnose virFileReadAll
failure, since it already does that.
---
qemud/qemud.c | 20 ++++++++++++--------
src/conf.c | 3 +--
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index c3d3c02..9835e0a 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -1,7 +1,7 @@
/*
* qemud.c: daemon start of day, guest process & i/o management
*
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -2116,13 +2116,8 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
auth_unix_ro = REMOTE_AUTH_NONE;
#endif
- /* Just check the file is readable before opening it, otherwise
- * libvirt emits an error.
- */
- if (access (filename, R_OK) == -1) return 0;
-
conf = virConfReadFile (filename);
- if (!conf) return 0;
+ if (!conf) return -1;
/*
* First get all the logging settings and activate them
@@ -2301,7 +2296,7 @@ int main(int argc, char **argv) {
struct sigaction sig_action;
int sigpipe[2];
const char *pid_file = NULL;
- const char *remote_config_file = SYSCONF_DIR "/libvirt/libvirtd.conf";
+ const char *remote_config_file = NULL;
int ret = 1;
struct option opts[] = {
@@ -2372,6 +2367,15 @@ int main(int argc, char **argv) {
}
}
+ if (remote_config_file == NULL) {
+ static const char *default_config_file
+ = SYSCONF_DIR "/libvirt/libvirtd.conf";
+ remote_config_file =
+ (access(default_config_file, X_OK) == 0
+ ? default_config_file
+ : "/dev/null");
+ }
+
if (godaemon) {
if (qemudGoDaemon() < 0) {
VIR_ERROR(_("Failed to fork as daemon: %s"), strerror(errno));
diff --git a/src/conf.c b/src/conf.c
index 9f0fc34..339a150 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,7 +1,7 @@
/**
* conf.c: parser for a subset of the Python encoded Xen configuration files
*
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -712,7 +712,6 @@ virConfReadFile(const char *filename)
}
if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0) {
- virConfError(NULL, VIR_ERR_OPEN_FAILED, filename);
return NULL;
}
--
1.6.1.141.gfe98e
>From e70a4556a8422779b7997ab03997af4b9a03087c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 8 Jan 2009 19:58:19 +0100
Subject: [PATCH 2/3] tests: quiet virsh-all
* tests/virsh-all: For now, ignore diagnostics and exit status,
when running all virsh commands.
---
tests/virsh-all | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/virsh-all b/tests/virsh-all
index f1c84a3..03ea466 100755
--- a/tests/virsh-all
+++ b/tests/virsh-all
@@ -1,7 +1,7 @@
#!/bin/sh
# blindly run each and every command listed by "virsh help"
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,7 +35,8 @@ test -n "$cmds" || framework_failure
for i in $cmds; do
echo testing $i... 1>&2
- virsh -c $test_url $i < /dev/null
+ # For now, just run the command and ignore output and exit status.
+ virsh -c $test_url $i < /dev/null > /dev/null 2>&1
done
(exit $fail); exit $fail
--
1.6.1.141.gfe98e
>From 307c465a008cbb4a497a6553046a036e95843519 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 8 Jan 2009 20:18:17 +0100
Subject: [PATCH 3/3] add two tests
* tests/libvirtd-pool: New file.
* tests/libvirtd-fail: New file.
* tests/Makefile.am (test_scripts): Add omitted backslash,
so that the virsh-all test is run.
Add libvirtd-fail and libvirtd-pool.
---
tests/Makefile.am | 24 ++++++++++++----------
tests/libvirtd-fail | 20 +++++++++++++++++++
tests/libvirtd-pool | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 11 deletions(-)
create mode 100755 tests/libvirtd-fail
create mode 100755 tests/libvirtd-pool
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d8b5e44..a3e4383 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -56,17 +56,19 @@ endif
test_scripts = domainschematest
if WITH_LIBVIRTD
-test_scripts += \
- test_conf.sh \
- cpuset \
- daemon-conf \
- int-overflow \
- read-bufsiz \
- read-non-seekable \
- start \
- undefine \
- vcpupin
- virsh-all
+test_scripts += \
+ cpuset \
+ daemon-conf \
+ int-overflow \
+ libvirtd-fail \
+ libvirtd-pool \
+ read-bufsiz \
+ read-non-seekable \
+ start \
+ test_conf.sh \
+ undefine \
+ vcpupin \
+ virsh-all \
virsh-synopsis
endif
diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail
new file mode 100755
index 0000000..724d7c6
--- /dev/null
+++ b/tests/libvirtd-fail
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Ensure that libvirt fails when given nonexistent --config=FILE
+
+if test "$VERBOSE" = yes; then
+ set -x
+ libvirtd --version
+fi
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+libvirtd --config=no-such-file > log 2>&1 && fail=1
+cat <<\EOF > exp
+Failed to open file 'no-such-file': No such file or directory
+EOF
+
+compare exp log
diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool
new file mode 100755
index 0000000..72afa12
--- /dev/null
+++ b/tests/libvirtd-pool
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Get coverage of libvirtd's config-parsing code.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ libvirtd --version
+ virsh --version
+fi
+
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+libvirtd > log 2>&1 & pid=$!
+sleep 1
+
+virsh --connect qemu:///session \
+ pool-define-as P dir src-host /src/path /src/dev S /target-path > out 2>&1 \
+ || fail=1
+virsh --connect qemu:///session pool-dumpxml P >> out 2>&1 || fail=1
+
+# remove random uuid
+sed 's/<uuid>.*/-/' out > k && mv k out || fail=1
+
+kill $pid
+
+cat <<EOF > exp
+Pool P defined
+
+<pool type='dir'>
+ <name>P</name>
+ -
+ <capacity>0</capacity>
+ <allocation>0</allocation>
+ <available>0</available>
+ <source>
+ </source>
+ <target>
+ <path>/target-path</path>
+ <permissions>
+ <mode>0700</mode>
+ <owner>500</owner>
+ <group>500</group>
+ </permissions>
+ </target>
+</pool>
+
+EOF
+
+compare exp out
+compare /dev/null log
--
1.6.1.141.gfe98e
15 years, 10 months
[libvirt] [PATCH] Solaris PV is localtime. Allow this setting through the conversions
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233198416 28800
# Node ID 76d670ab6ea5476be96441ea88af94644c985201
# Parent f0247b9f4da199c01412d5bd0f9d7d888cbb84de
Solaris PV is localtime. Allow this setting through the conversions.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -2272,10 +2272,12 @@ xenDaemonParseSxpr(virConnectPtr conn,
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
if (sexpr_int(root, "domain/image/hvm/pae"))
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
-
- if (sexpr_int(root, "domain/image/hvm/localtime"))
+ }
+
+ if (sexpr_int(root, "domain/localtime") ||
+ sexpr_int(root, "domain/image/hvm/localtime") ||
+ sexpr_int(root, "domain/image/linux/localtime"))
def->localtime = 1;
- }
if (sexpr_node_copy(root, hvm ?
"domain/image/hvm/device_model" :
@@ -5338,6 +5340,14 @@ xenDaemonFormatSxpr(virConnectPtr conn,
}
virBufferVSprintf(&buf, "(on_crash '%s')", tmp);
+ /*
+ * xend puts localtime in image/{hvm,linux}/, but is clearly
+ * bootloader independent. As a simple workaround, we define it
+ * here - xend happily picks it up from here.
+ */
+ if (def->localtime)
+ virBufferAddLit(&buf, "(localtime 1)");
+
if (!def->os.bootloader) {
if (STREQ(def->os.type, "hvm"))
hvm = 1;
@@ -5453,9 +5463,6 @@ xenDaemonFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, "(serial none)");
}
- if (def->localtime)
- virBufferAddLit(&buf, "(localtime 1)");
-
if (def->sounds) {
virBufferAddLit(&buf, "(soundhw '");
if (xenDaemonFormatSxprSound(conn, def, &buf) < 0)
diff --git a/src/xm_internal.c b/src/xm_internal.c
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -818,10 +818,11 @@ xenXMDomainConfigParse(virConnectPtr con
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
-
- if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime, 0) < 0)
- goto cleanup;
- }
+ }
+
+ if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime, 0) < 0)
+ goto cleanup;
+
if (xenXMConfigCopyStringOpt(conn, conf, "device_model", &def->emulator) < 0)
goto cleanup;
@@ -1972,6 +1973,9 @@ virConfPtr xenXMDomainConfigFormat(virCo
if (xenXMConfigSetInt(conf, "vcpus", def->vcpus) < 0)
goto no_memory;
+ if (def->localtime && xenXMConfigSetInt(conf, "localtime", 1) < 0)
+ goto no_memory;
+
if (def->cpumask &&
!(cpus = virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen)) < 0)
goto cleanup;
@@ -2034,9 +2038,6 @@ virConfPtr xenXMDomainConfigFormat(virCo
(1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0)
goto no_memory;
-
- if (xenXMConfigSetInt(conf, "localtime", def->localtime ? 1 : 0) < 0)
- goto no_memory;
if (priv->xendConfigVersion == 1) {
for (i = 0 ; i < def->ndisks ; i++) {
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr
@@ -0,0 +1,1 @@
+(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(localtime 1)(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 ioemu))))
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml
@@ -0,0 +1,41 @@
+<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='localtime'/>
+ <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'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='5903' autoport='no' keymap='ja'/>
+ </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr
@@ -0,0 +1,2 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(localtime 1)(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
+
diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml
@@ -0,0 +1,27 @@
+<domain type='xen' id='6'>
+ <name>pvtest</name>
+ <uuid>596a5d21-71f4-8fb2-e068-e2386a5c413e</uuid>
+ <memory>430080</memory>
+ <currentMemory>430080</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type>linux</type>
+ <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+ <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+ <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... </cmdline>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file'/>
+ <source file='/root/some.img'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -129,6 +129,7 @@ mymain(int argc, char **argv)
DO_TEST("pv-vfb-new-vncdisplay", "pv-vfb-new-vncdisplay", 3);
DO_TEST("fv-autoport", "fv-autoport", 3);
DO_TEST("pv-bootloader", "pv-bootloader", 1);
+ DO_TEST("pv-localtime", "pv-localtime", 1);
DO_TEST("disk-file", "disk-file", 2);
DO_TEST("disk-block", "disk-block", 2);
@@ -145,6 +146,7 @@ mymain(int argc, char **argv)
DO_TEST("fv-utc", "fv-utc", 1);
DO_TEST("fv-localtime", "fv-localtime", 1);
+ DO_TEST("fv-localtime2", "fv-localtime2", 1);
DO_TEST("fv-usbmouse", "fv-usbmouse", 1);
DO_TEST("fv-usbtablet", "fv-usbtablet", 1);
DO_TEST("fv-kernel", "fv-kernel", 1);
diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg
--- a/tests/xmconfigdata/test-escape-paths.cfg
+++ b/tests/xmconfigdata/test-escape-paths.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg
--- a/tests/xmconfigdata/test-fullvirt-localtime.cfg
+++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg
@@ -3,13 +3,13 @@ maxmem = 579
maxmem = 579
memory = 394
vcpus = 1
+localtime = 1
builder = "hvm"
kernel = "/usr/lib/xen/boot/hvmloader"
boot = "d"
pae = 1
acpi = 1
apic = 1
-localtime = 1
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
--- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
+++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
--- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
+++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
cdrom = "/root/boot.iso"
on_poweroff = "destroy"
on_reboot = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg
--- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg
+++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg
+++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg
--- a/tests/xmconfigdata/test-fullvirt-sound.cfg
+++ b/tests/xmconfigdata/test-fullvirt-sound.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg
--- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg
+++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg
--- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg
+++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg
--- a/tests/xmconfigdata/test-fullvirt-utc.cfg
+++ b/tests/xmconfigdata/test-fullvirt-utc.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg
--- a/tests/xmconfigdata/test-no-source-cdrom.cfg
+++ b/tests/xmconfigdata/test-no-source-cdrom.cfg
@@ -9,7 +9,6 @@ pae = 1
pae = 1
acpi = 1
apic = 1
-localtime = 0
on_poweroff = "destroy"
on_reboot = "destroy"
on_crash = "destroy"
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
--- a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
+++ b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
@@ -1,1 +1,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)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime 1)(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 ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(localtime 1)(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(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 ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr
@@ -0,0 +1,1 @@
+(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(localtime 1)(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml
@@ -0,0 +1,24 @@
+<domain type='xen' id='15'>
+ <name>pvtest</name>
+ <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+ <os>
+ <type>linux</type>
+ <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+ <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+ <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... </cmdline>
+ </os>
+ <memory>430080</memory>
+ <vcpu>2</vcpu>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <source file='/root/some.img'/>
+ <target dev='xvda'/>
+ </disk>
+ <console tty='/dev/pts/4'/>
+ </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr
@@ -0,0 +1,1 @@
+(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-utc.xml b/tests/xml2sexprdata/xml2sexpr-pv-utc.xml
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-pv-utc.xml
@@ -0,0 +1,24 @@
+<domain type='xen' id='15'>
+ <name>pvtest</name>
+ <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+ <os>
+ <type>linux</type>
+ <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+ <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+ <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test... </cmdline>
+ </os>
+ <memory>430080</memory>
+ <vcpu>2</vcpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <source file='/root/some.img'/>
+ <target dev='xvda'/>
+ </disk>
+ <console tty='/dev/pts/4'/>
+ </devices>
+</domain>
+
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -112,6 +112,8 @@ mymain(int argc, char **argv)
DO_TEST("pv-vfb-new", "pv-vfb-new", "pvtest", 3);
DO_TEST("pv-vfb-new-auto", "pv-vfb-new-auto", "pvtest", 3);
DO_TEST("pv-bootloader", "pv-bootloader", "pvtest", 1);
+ DO_TEST("pv-localtime", "pv-localtime", "pvtest", 1);
+ DO_TEST("pv-utc", "pv-utc", "pvtest", 1);
DO_TEST("disk-file", "disk-file", "pvtest", 2);
DO_TEST("disk-block", "disk-block", "pvtest", 2);
15 years, 10 months
[libvirt] [PATCH/RFC]: don't ignore errors to save the domain status file
by Guido Günther
Hi,
we currently don't report errors to save qemu's domain status file back
to the caller. That was o.k. as long as the code was there for testing
but now that the XML is being picked up on daemon restart we must
handle these.
The attached patch does that, although I'm not confident that it's
enough. While we return error on device attach/unattach the device
actually got attached/unattached already. Same is true for
suspend/resume.
A better solution would be to write out the new domain status into a
temp file and simply call rename(2) on it when the attach/unattach
succeeds and discard it if it fails. This would minimize the possible
error conditions like disk full, missing permissions to write into that
directory etc. Does this sound reasonable?
O.k. to apply the attached version for now?
Cheers,
-- Guido
15 years, 10 months
[libvirt] RFC: configuring host interfaces with libvirt
by David Lutterkort
For certain applications, we want libvirt to be able to configure host
network interfaces in a variety of ways; currently, we are most
interested in teaching libvirt how to set up ordinary ethernet
interfaces, bridges, bonding and vlan's.
Below is a high-level proposal of how that could be done. Please comment
copiously ;)
1. XML Format
=============
The first question is how the user would describe the host interfaces they
want. Below are some sketches of what an XML representation of the various
kinds of interfaces would look like. This covers the minimal amount of
settings for these to be useful, though I am sure we'll need to add more
over time.
<interface device="eth0" onboot="yes">
<hwaddr>00:19:d2:9f:88:96</hwaddr>
<dhcp peerdns="yes"/>
</interface>
<interface device="eth1" onboot="yes">
<hwaddr>00:19:d2:9f:88:97</hwaddr>
<static ipaddr="192.168.0.5" gateway="192.168.0.1" netmask="255.255.255.0"/>
</interface>
<interface device="eth2" onboot="yes">
<hwaddr>00:19:d2:9f:88:98</hwaddr>
</interface>
<bond name="bond00" onboot="yes" mode="active-backup">
<slave device="eth0" primary="yes"/>
<slave device="eth1"/>
</bond>
<bridge name="br0" stp="off" onboot="yes">
<member device="eth2"/>
<dhcp peerdns="yes"/>
</bridge>
<vlan device="eth0" tag="42" reorder_hdr="yes"/>
All of these should also allow a <uuid> element for specifying a uuid; I
omitted that for brevity.
2. API Changes
==============
There are two options for dealing with network interfaces: (1) use the
existing virNetwork* calls or (2) add completely new API calls.
Repurposing existing virNetwork* calls
--------------------------------------
The existing calls map well to the operations we need for managing
interfaces, with a few exceptions:
- virNetworkGetAutostart/SetAutostart: depending on how we implement all
this (see below), 'autostart' might actually mean 'on boot', not 'when
libvirtd starts'
- virNetworkGetBridgeName doesn't make sense for interfaces, and should
return NULL for interfaces
We'll probably also end up adding some functions to query details about an
interface, in particular, a call to see what kind of network/interface a
virNetworkPtr represents
Add completely new virInterface* calls
--------------------------------------
This would add roughly the same API calls as the virNetwork* calls,
i.e. we'd have something like
typedef struct virInterface *virInterfacePtr;
int virInterfaceCreate(virInterfacePtr);
virInterfacePtr virInterfaceCreateXML(..);
...
plus some calls to extract information from a virInterfacePtr
The second option seems cleaner to me and easier to implement, and avoids
any subtle changes in the behavior of existing API, though I don't like
that we'll be adding another 20 or so calls to libvirt's public API, with
attendant churn both in the drivers and in virsh.
3. Implementation
=================
Configuring network interfaces is highly OS and OS-variant/distro
dependant. There are at least two different ways how libvirt can go about
modifying the host to create interfaces:
1. Modify the system's network setup scripts (ifcfg-XXX on RH)
2. Directly use the system's network utilities like ifconfig
3. Rely on NetworkManager (not an option right now, as NM doesn't know
about bridges and the like)
Option (1) saves us from replicating every bit of network setup
functionality that those scripts already have - besides configuring the
interface, we also might have to setup routes, run dhclient etc.
Option (2) would require far fewer backend implementations than (1) - we
should be able to get away with one implementation for Linux, rather than
one for Fedora/RHEL, one for Debian, one for SuSe, three for gentoo
etc.
If we want 'autostart' for an interface to mean 'bring up the interface
as soon as the system boots', we are pretty much forced to go with
option (1).
All in all, option (1) seems more attractive, since it should save us from
dealing with a lot of low-level details of network setup, and the distro
scripts should be much better integrated with the rest of the system than
what we come up with for libvirt.
4. Misc issues
==============
* Should interfaces have labels/roles ('data-interface') to help admins
make sense of the current config ?
* Do we expect interfaces to be in a specific state before we create them
or do we just tear them down and reconfigure them no matter what ?
* Are there crucial config options that are not covered by the sketches
above (e.g., setting an explicit MTU) ? Are there things in the XML
sketches above that will be impossible to implement on some OS ?
* Should this even be done as part of libvirt ? It seems like a very
generic network config tool, and libvirt merely the conduit to exposing
this through an API, most importantly, a remotable API.
David
15 years, 10 months
[libvirt] autostart with xend
by John Levon
It doesn't work quite right with a running domain. The 'new' will
correctly set the config, but the temporary config doesn't include the
new setting. So tests of the form "set autostart; is it set?" will fail.
Suggestions?
Also, why isn't this represented in the XML?
thanks,
john
15 years, 10 months
[libvirt] [PATCH] Add <distro> to domain XML
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233340700 28800
# Node ID c1cc701bfb5b7417c2c8cd3571022dcd161c518f
# Parent cb53cd19242ca7c4a8d20a54495108d7f6639e57
Add <distro> to domain XML
Support recording the distro type and variant of a domain.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -19,6 +19,7 @@
<ref name='resources'/>
<ref name='features'/>
<ref name='termination'/>
+ <ref name='distro'/>
<optional>
<ref name='devices'/>
</optional>
@@ -326,6 +327,20 @@
</attribute>
<empty/>
</element>
+ </define>
+
+
+ <define name='distro'>
+ <optional>
+ <element name='distro'>
+ <element name='type'>
+ <text/>
+ </element>
+ <element name='variant'>
+ <text/>
+ </element>
+ </element>
+ </optional>
</define>
diff --git a/src/domain_conf.c b/src/domain_conf.c
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -436,6 +436,8 @@ void virDomainDefFree(virDomainDefPtr de
VIR_FREE(def->name);
VIR_FREE(def->cpumask);
VIR_FREE(def->emulator);
+ VIR_FREE(def->distro_type);
+ VIR_FREE(def->distro_variant);
VIR_FREE(def);
}
@@ -2010,6 +2012,9 @@ static virDomainDefPtr virDomainDefParse
&def->onCrash, VIR_DOMAIN_LIFECYCLE_DESTROY) < 0)
goto error;
+ def->distro_type = virXPathString(conn, "string(./distro/type[1])", ctxt);
+ def->distro_variant = virXPathString(conn,
+ "string(./distro/variant[1])", ctxt);
tmp = virXPathString(conn, "string(./clock/@offset)", ctxt);
if (tmp && STREQ(tmp, "localtime"))
@@ -3352,6 +3357,17 @@ char *virDomainDefFormat(virConnectPtr c
"on_crash") < 0)
goto cleanup;
+ if (def->distro_type != NULL) {
+ virBufferAddLit(&buf, " <distro>\n");
+ virBufferEscapeString(&buf, " <type>%s</type>\n",
+ def->distro_type);
+ if (def->distro_variant != NULL) {
+ virBufferEscapeString(&buf, " <variant>%s</variant>\n",
+ def->distro_variant);
+ }
+ virBufferAddLit(&buf, " </distro>\n");
+ }
+
virBufferAddLit(&buf, " <devices>\n");
if (def->emulator)
diff --git a/src/domain_conf.h b/src/domain_conf.h
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -428,6 +428,9 @@ struct _virDomainDef {
int onReboot;
int onPoweroff;
int onCrash;
+
+ char *distro_type;
+ char *distro_variant;
virDomainOSDef os;
char *emulator;
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -2274,6 +2274,14 @@ xenDaemonParseSxpr(virConnectPtr conn,
}
} else
def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
+
+ tmp = sexpr_node(root, "domain/distro_type");
+ if (tmp != NULL && (def->distro_type = strdup(tmp)) == NULL)
+ goto no_memory;
+
+ tmp = sexpr_node(root, "domain/distro_variant");
+ if (tmp != NULL && (def->distro_variant = strdup(tmp)) == NULL)
+ goto no_memory;
if (hvm) {
@@ -5337,6 +5345,11 @@ xenDaemonFormatSxpr(virConnectPtr conn,
}
virBufferVSprintf(&buf, "(on_crash '%s')", tmp);
+ if (def->distro_type != NULL)
+ virBufferVSprintf(&buf, "(distro_type '%s')", def->distro_type);
+ if (def->distro_variant != NULL)
+ virBufferVSprintf(&buf, "(distro_variant '%s')", def->distro_variant);
+
/*
* xend puts localtime in image/{hvm,linux}/, but is clearly
* bootloader independent. As a simple workaround, we define it
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-distro.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-distro.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-distro.sexpr
@@ -0,0 +1,86 @@
+(domain
+ (domid 1)
+ (on_crash destroy)
+ (uuid 7dbd82d8-bd75-72ea-0f23-f988c4ef95bd)
+ (bootloader_args )
+ (vcpus 1)
+ (name domu-220)
+ (on_poweroff destroy)
+ (on_reboot destroy)
+ (bootloader )
+ (maxmem 1024)
+ (memory 1024)
+ (shadow_memory 9)
+ (cpu_weight 256)
+ (cpu_cap 0)
+ (features )
+ (on_xend_start ignore)
+ (on_xend_stop shutdown)
+ (start_time 1233338703.67)
+ (cpu_time 31.675171334)
+ (online_vcpus 1)
+ (distro_type windows)
+ (distro_variant winxp)
+ (image
+ (hvm
+ (kernel /usr/lib/xen/boot/hvmloader)
+ (boot d)
+ (device_model /usr/lib/xen/bin/qemu-dm)
+ (keymap en-us)
+ (localtime 1)
+ (pae 1)
+ (serial pty)
+ (usb 1)
+ (usbdevice tablet)
+ (notes (SUSPEND_CANCEL 1))
+ )
+ )
+ (status 2)
+ (state r-----)
+ (store_mfn 262142)
+ (device
+ (vif
+ (mac 00:16:36:1a:73:6d)
+ (script vif-vnic)
+ (uuid e81f0e1a-69d9-fd9a-6bee-540693c66eeb)
+ (backend 0)
+ )
+ )
+ (device
+ (vbd
+ (uname phy:/dev/zvol/dsk/export/dom/domu-220-root)
+ (uuid 4e71c222-f7cf-7fac-bae3-dc57f1e3f2bc)
+ (mode w)
+ (dev hda:disk)
+ (backend 0)
+ (bootable 1)
+ )
+ )
+ (device
+ (vbd
+ (uname file:/net/heaped/export/netimage/windows/xp-sp2-vol.iso)
+ (uuid 2f321f31-80c9-c71e-cb80-0e6a932b071b)
+ (mode r)
+ (dev hdc:cdrom)
+ (backend 0)
+ (bootable 0)
+ )
+ )
+ (device (vkbd (backend 0)))
+ (device
+ (vfb
+ (vncunused 1)
+ (keymap en-us)
+ (type vnc)
+ (uuid a296597b-b5ac-a5b6-05c5-1d98200c528f)
+ (location localhost:5900)
+ )
+ )
+ (device
+ (console
+ (protocol vt100)
+ (location 3)
+ (uuid 8665fe81-678a-4ddc-5f8d-24e3d5fa46d9)
+ )
+ )
+)
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-distro.xml b/tests/sexpr2xmldata/sexpr2xml-fv-distro.xml
new file mode 100644
--- /dev/null
+++ b/tests/sexpr2xmldata/sexpr2xml-fv-distro.xml
@@ -0,0 +1,51 @@
+<domain type='xen' id='1'>
+ <name>domu-220</name>
+ <uuid>7dbd82d8-bd75-72ea-0f23-f988c4ef95bd</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <distro>
+ <type>windows</type>
+ <variant>winxp</variant>
+ </distro>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/dev/zvol/dsk/export/dom/domu-220-root'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='file'/>
+ <source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <interface type='ethernet'>
+ <mac address='00:16:36:1a:73:6d'/>
+ <script path='vif-vnic'/>
+ <target dev='vif1.0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='tablet' bus='usb'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
+ </devices>
+</domain>
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -150,6 +150,7 @@ mymain(int argc, char **argv)
DO_TEST("fv-usbmouse", "fv-usbmouse", 1);
DO_TEST("fv-usbtablet", "fv-usbtablet", 1);
DO_TEST("fv-kernel", "fv-kernel", 1);
+ DO_TEST("fv-distro", "fv-distro", 3);
DO_TEST("fv-serial-null", "fv-serial-null", 1);
DO_TEST("fv-serial-file", "fv-serial-file", 1);
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-distro.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-distro.sexpr
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-fv-distro.sexpr
@@ -0,0 +1,1 @@
+(vm (name 'domu-220')(memory 1024)(maxmem 1024)(vcpus 1)(uuid '7dbd82d8-bd75-72ea-0f23-f988c4ef95bd')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(distro_type 'windows')(distro_variant 'winxp')(localtime 1)(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot d)(pae 1)(usb 1)(usbdevice tablet)(parallel none)(serial pty)(device_model '/usr/lib/xen/bin/qemu-dm')(vnc 1)(vncunused 1)(keymap 'en-us')))(device (vbd (dev 'hda:disk')(uname 'phy:/dev/zvol/dsk/export/dom/domu-220-root')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(uname 'file:/net/heaped/export/netimage/windows/xp-sp2-vol.iso')(mode 'r')))(device (vif (mac '00:16:36:1a:73:6d')(script 'vif-vnic')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-distro.xml b/tests/xml2sexprdata/xml2sexpr-fv-distro.xml
new file mode 100644
--- /dev/null
+++ b/tests/xml2sexprdata/xml2sexpr-fv-distro.xml
@@ -0,0 +1,51 @@
+<domain type='xen' id='1'>
+ <name>domu-220</name>
+ <uuid>7dbd82d8-bd75-72ea-0f23-f988c4ef95bd</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <distro>
+ <type>windows</type>
+ <variant>winxp</variant>
+ </distro>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/dev/zvol/dsk/export/dom/domu-220-root'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='file'/>
+ <source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <interface type='ethernet'>
+ <mac address='00:16:36:1a:73:6d'/>
+ <script path='vif-vnic'/>
+ <target dev='vif1.0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='tablet' bus='usb'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
+ </devices>
+</domain>
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -136,6 +136,7 @@ mymain(int argc, char **argv)
DO_TEST("fv-usbmouse", "fv-usbmouse", "fvtest", 1);
DO_TEST("fv-usbmouse", "fv-usbmouse", "fvtest", 1);
DO_TEST("fv-kernel", "fv-kernel", "fvtest", 1);
+ DO_TEST("fv-distro", "fv-distro", "fvtest", 3);
DO_TEST("fv-serial-null", "fv-serial-null", "fvtest", 1);
DO_TEST("fv-serial-file", "fv-serial-file", "fvtest", 1);
15 years, 10 months