[libvirt] [PATCH] virsh: Pretty the output of qemu-agent-command
by Osier Yang
This adds a new option "--pretty" for qemu-agent-command, to
pretty-format the returned JSON string.
---
tools/virsh-domain.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 546b182..bb94ac1 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7605,6 +7605,10 @@ static const vshCmdOptDef opts_qemu_agent_command[] = {
.type = VSH_OT_BOOL,
.help = N_("execute command without timeout")
},
+ {.name = "pretty",
+ .type = VSH_OT_BOOL,
+ .help = N_("pretty-print the output")
+ },
{.name = "cmd",
.type = VSH_OT_ARGV,
.flags = VSH_OFLAG_REQ,
@@ -7626,6 +7630,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
const vshCmdOpt *opt = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool pad = false;
+ virJSONValuePtr pretty = NULL;
dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL)
@@ -7670,6 +7675,17 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
}
result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
+ if (vshCommandOptBool(cmd, "pretty")) {
+ char *tmp;
+ pretty = virJSONValueFromString(result);
+ if (pretty && (tmp = virJSONValueToString(pretty, true))) {
+ VIR_FREE(result);
+ result = tmp;
+ } else {
+ vshResetLibvirtError();
+ }
+ }
+
vshPrint(ctl, "%s\n", result);
ret = true;
--
1.8.1.4
11 years, 6 months
[libvirt] [libvirt PATCH] virsh: Use vshPrint instead of printf
by Osier Yang
---
tools/virsh-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 86786ee..546b182 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7670,7 +7670,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
}
result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
- if (result) printf("%s\n", result);
+ vshPrint(ctl, "%s\n", result);
ret = true;
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCH] Fix invalid argument reference in virnetdev.h
by Martin Kletzander
Commit ccff335f added ATTRIBUTE_NONNULL for an attribute which is not
a pointer and made files including virnetdev.h not compilable, so fix
that.
---
Pushed under the build-breaker rule.
src/util/virnetdev.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 0b394ad..bc0777c 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -48,7 +48,7 @@ int virNetDevAddRoute(const char *ifname,
virSocketAddrPtr gateway,
unsigned int metric)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4)
- ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_RETURN_CHECK;
int virNetDevClearIPv4Address(const char *ifname,
virSocketAddr *addr,
unsigned int prefix)
--
1.8.2.1
11 years, 6 months
[libvirt] [libvirt PATCH 0/8] Fixes for cgroup setting
by Osier Yang
1/8 ~ 5/8 are refactorings, real fixes are 6/8, 7/8. 8/8 is RFC.
Osier Yang (8):
qemu: Abstract the code for blkio controller setting into a helper
qemu: Abstract code for memory controller setting into a helper
qemu: Abstract code for devices controller setting into a helper
qemu: Abstract code for cpuset controller setting into a helper
qemu: Abstract code for the cpu controller setting into a helper
qemu: Set cpuset.cpus for domain process
qemu: Prohibit getting the numa parameters if mode is not strict
qemu: Set cpuset.mems even if the numatune mode is not strict
src/qemu/qemu_cgroup.c | 564 +++++++++++++++++++++++++++++--------------------
src/qemu/qemu_driver.c | 11 +-
2 files changed, 348 insertions(+), 227 deletions(-)
--
1.8.1.4
11 years, 6 months
[libvirt] libxl requires libuuid?
by Eric Blake
I got this compile error on a relatively new rawhide machine install:
CC libvirt_driver_libxl_impl_la-libxl_conf.lo
In file included from /usr/include/libxl.h:259:0,
from libxl/libxl_conf.c:29:
/usr/include/libxl_uuid.h:27:23: fatal error: uuid/uuid.h: No such file
or directory
#include <uuid/uuid.h>
^
compilation terminated.
Is this a case of the libxl development package not pulling in enough
pre-reqs? Does libvirt need to work around this, or do I just file a
bug against libxl?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
11 years, 6 months
[libvirt] [PATCH] storage: Ensure 'qemu-img resize' size arg is a 512 multiple
by Christophe Fergeau
qemu-img resize will fail with "The new size must be a multiple of 512"
if libvirt doesn't round it first.
This fixes rhbz#951495
Signed-off-by: Christophe Fergeau <cfergeau(a)redhat.com>
---
src/storage/storage_backend_fs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 9b83e57..99973b0 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1219,6 +1219,10 @@ virStorageBackendFilesystemResizeQemuImg(const char *path,
return -1;
}
+ /* Round capacity up to the closest 512 multiple as qemu-img errors out
+ * on sizes which are not a multiple of 512 */
+ capacity = (capacity + 511) / 512 * 512;
+
cmd = virCommandNew(img_tool);
virCommandAddArgList(cmd, "resize", path, NULL);
virCommandAddArgFormat(cmd, "%llu", capacity);
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] docs: Fix the wrong links in secret documentation
by Osier Yang
docs/formatsecret.html.in: (s/domain\.html/formatdomain\.html/g)
---
Pushed under trivial rule.
---
docs/formatsecret.html.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/formatsecret.html.in b/docs/formatsecret.html.in
index cfea459..50c9533 100644
--- a/docs/formatsecret.html.in
+++ b/docs/formatsecret.html.in
@@ -64,7 +64,7 @@
a single <code>name</code> element that specifies a usage name
for the secret. The Ceph secret can then be used by UUID or by
this usage name via the <code><auth></code> element of
- a <a href="domain.html#elementsDisks">disk
+ a <a href="formatdomain.html#elementsDisks">disk
device</a>. <span class="since">Since 0.9.7</span>.
</p>
@@ -76,7 +76,7 @@
a single <code>target</code> element that specifies a usage name
for the secret. The iSCSI secret can then be used by UUID or by
this usage name via the <code><auth></code> element of
- a <a href="domain.html#elementsDisks">disk
+ a <a href="formatdomain.html#elementsDisks">disk
device</a>. <span class="since">Since 1.0.4</span>.
</p>
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCH] docs: Add the missed usage type 'iscsi'
by Osier Yang
Pushed under trivial rule.
---
docs/formatsecret.html.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/formatsecret.html.in b/docs/formatsecret.html.in
index f816b50..cfea459 100644
--- a/docs/formatsecret.html.in
+++ b/docs/formatsecret.html.in
@@ -41,8 +41,8 @@
<dd>
Specifies what this secret is used for. A mandatory
<code>type</code> attribute specifies the usage category, currently
- only <code>volume</code> and <code>ceph</code> are defined.
- Specific usage categories are described below.
+ only <code>volume</code>, <code>ceph</code> and <code>iscsi</code>
+ are defined. Specific usage categories are described below.
</dd>
</dl>
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCHv3] Configure native vlan modes on Open vSwitch ports
by james robson
This patch adds functionality to allow libvirt to configure the
'native-tagged' and 'native-untagged' modes on openvswitch networks.
v2 changes:
Fix problems reported by Eric Blake
v3 changes:
Re work patch to address review comments
---
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 888c005..5278534 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3290,6 +3290,13 @@ qemu-kvm -net nic,model=? /dev/null
<parameters
interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
</virtualport>
</interface>
+ <interface type='bridge'>
+ <b><vlan trunk='yes'></b>
+ <b><tag id='42'/></b>
+ <b><tag id='123' nativeMode='untagged'/></b>
+ <b></vlan></b>
+ ...
+ </interface>
<devices>
...</pre>
@@ -3316,6 +3323,15 @@ qemu-kvm -net nic,model=? /dev/null
vlan element.
</p>
+ <p>
+ For network connections using openvswitch it is possible to
+ configure the 'native-tagged' and 'native-untagged' vlan modes
+ <span class="since">(Since 1.0.6).</span> This uses the optional
+ <code>nativeMode</code> attribute on the <code><tag></code>
+ element: <code>nativeMode</code> may be set to 'tagged' or
+ 'untagged'. The id atribute of the element sets the native vlan.
+ </p>
+
<h5><a name="elementLink">Modifying virtual link state</a></h5>
<pre>
...
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 4dd0415..e065ca4 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -414,6 +414,7 @@
<span class="since">Since 0.9.4</span>
</p>
+
<h5><a name="elementVlanTag">Setting VLAN tag (on supported network
types only)</a></h5>
<pre>
@@ -429,6 +430,13 @@
<parameters
interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
</virtualport>
</interface>
+ <interface type='bridge'>
+ <b><vlan trunk='yes'></b>
+ <b><tag id='42'/></b>
+ <b><tag id='123' nativeMode='untagged'/></b>
+ <b></vlan></b>
+ ...
+ </interface>
<devices>
...</pre>
@@ -452,6 +460,14 @@
be added to the vlan element.
</p>
<p>
+ For network connections using openvswitch it is possible to
+ configure the 'native-tagged' and 'native-untagged' vlan modes
+ <span class="since">(Since 1.0.6).</span> This uses the optional
+ <code>nativeMode</code> attribute on the <code><tag></code>
+ element: <code>nativeMode</code> may be set to 'tagged' or
+ 'untagged'. The id atribute of the element sets the native vlan.
+ </p>
+ <p>
<code><vlan></code> elements can also be specified in
a <code><portgroup></code> element, as well as directly in
a domain's <code><interface></code> element. In the case
diff --git a/docs/schemas/networkcommon.rng
b/docs/schemas/networkcommon.rng
index 51ff759..e60f1fc 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -204,6 +204,14 @@
<param name="maxInclusive">4095</param>
</data>
</attribute>
+ <optional>
+ <attribute name="nativeMode">
+ <choice>
+ <value>tagged</value>
+ <value>untagged</value>
+ </choice>
+ </attribute>
+ </optional>
<empty/>
</element>
</oneOrMore>
diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c
index 13ba8c6..dd5b64e 100644
--- a/src/conf/netdev_vlan_conf.c
+++ b/src/conf/netdev_vlan_conf.c
@@ -17,6 +17,7 @@
*
* Authors:
* Laine Stump <laine(a)redhat.com>
+ * James Robson <jrobson(a)websense.com>
*/
#include <config.h>
@@ -33,6 +34,7 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr
ctxt, virNetDevVlanPtr de
int ret = -1;
xmlNodePtr save = ctxt->node;
const char *trunk = NULL;
+ const char *nativeMode = NULL;
xmlNodePtr *tagNodes = NULL;
int nTags, ii;
@@ -54,6 +56,8 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr
ctxt, virNetDevVlanPtr de
goto error;
}
+ def->nativeMode = 0;
+ def->nativeTag = 0;
for (ii = 0; ii < nTags; ii++) {
unsigned long id;
@@ -68,6 +72,21 @@ virNetDevVlanParse(xmlNodePtr node,
xmlXPathContextPtr ctxt, virNetDevVlanPtr de
_("vlan tag id %lu too large (maximum
4095)"), id);
goto error;
}
+ if ((nativeMode = virXPathString("string(./@nativeMode)",
ctxt)) != NULL) {
+ if (STRCASENEQ(nativeMode, "tagged") &&
STRCASENEQ(nativeMode, "untagged")) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("invalid \"nativeMode='%s'\" in <tag>
- "
+ "native_mode must be 'tagged' or
'untagged'"), nativeMode);
+ goto error;
+ }
+ if (def->nativeMode != 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("duplicate native vlan setting"));
+ goto error;
+ }
+ def->nativeMode = STRCASEEQ(nativeMode, "tagged") ? 1 : 2;
+ def->nativeTag = id;
+ }
def->tag[ii] = id;
}
@@ -89,6 +108,12 @@ virNetDevVlanParse(xmlNodePtr node,
xmlXPathContextPtr ctxt, virNetDevVlanPtr de
"is required for more than one vlan
tag"), trunk);
goto error;
}
+ if (def->nativeMode != 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("invalid configuration in <vlan> -
\"trunk='no'\" is "
+ "not allowed with a native vlan id"));
+ goto error;
+ }
/* allow (but discard) "trunk='no' if there is a single tag
*/
if (STRCASENEQ(trunk, "no")) {
virReportError(VIR_ERR_XML_ERROR,
@@ -125,7 +150,11 @@ virNetDevVlanFormat(virNetDevVlanPtr def,
virBufferPtr buf)
virBufferAsprintf(buf, "<vlan%s>\n", def->trunk ? " trunk='yes'" :
"");
for (ii = 0; ii < def->nTags; ii++) {
- virBufferAsprintf(buf, " <tag id='%u'/>\n", def->tag[ii]);
+ if (def->nativeTag == def->tag[ii]) {
+ virBufferAsprintf(buf, " <tag id='%u' nativeMode='%
s'/>\n", def->tag[ii], def->nativeMode == 1 ? "tagged" : "untagged");
+ } else {
+ virBufferAsprintf(buf, " <tag id='%u'/>\n", def->tag[ii]);
+ }
}
virBufferAddLit(buf, "</vlan>\n");
return 0;
diff --git a/src/util/virnetdevopenvswitch.c
b/src/util/virnetdevopenvswitch.c
index 4fe077a..69cc1ac 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -19,6 +19,7 @@
* Dan Wendlandt <dan(a)nicira.com>
* Kyle Mestery <kmestery(a)cisco.com>
* Ansis Atteka <aatteka(a)nicira.com>
+ * James Robson <jrobson(a)websense.com>
*/
#include <config.h>
@@ -108,8 +109,13 @@ int virNetDevOpenvswitchAddPort(const char *brname,
const char *ifname,
virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist",
"add-port",
brname, ifname, NULL);
- if (virBufferUse(&buf) != 0)
+ if (virBufferUse(&buf) != 0) {
+ if (virtVlan->nativeMode > 0) {
+ virCommandAddArgFormat(cmd, "vlan_mode=%s",
virtVlan->nativeMode == 1 ? "native-tagged" : "native-untagged");
+ virCommandAddArgFormat(cmd, "tag=%d", virtVlan->nativeTag);
+ }
virCommandAddArgList(cmd, virBufferCurrentContent(&buf), NULL);
+ }
if (ovsport->profileID[0] == '\0') {
virCommandAddArgList(cmd,
diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c
index 2fe2017..b81c037 100644
--- a/src/util/virnetdevvlan.c
+++ b/src/util/virnetdevvlan.c
@@ -17,6 +17,7 @@
*
* Authors:
* Laine Stump <laine(a)redhat.com>
+ * James Robson <jrobson(a)websense.com>
*/
#include <config.h>
@@ -33,6 +34,8 @@ virNetDevVlanClear(virNetDevVlanPtr vlan)
{
VIR_FREE(vlan->tag);
vlan->nTags = 0;
+ vlan->nativeMode = 0;
+ vlan->nativeTag = 0;
}
void
@@ -54,7 +57,9 @@ virNetDevVlanEqual(const virNetDevVlanPtr a, const
virNetDevVlanPtr b)
return false;
if (a->trunk != b->trunk ||
- a->nTags != b->nTags) {
+ a->nTags != b->nTags ||
+ a->nativeMode != b->nativeMode ||
+ a->nativeTag != b->nativeTag) {
return false;
}
@@ -89,6 +94,8 @@ virNetDevVlanCopy(virNetDevVlanPtr dst, const
virNetDevVlanPtr src)
dst->trunk = src->trunk;
dst->nTags = src->nTags;
+ dst->nativeMode = src->nativeMode;
+ dst->nativeTag = src->nativeTag;
memcpy(dst->tag, src->tag, src->nTags * sizeof(*src->tag));
return 0;
}
diff --git a/src/util/virnetdevvlan.h b/src/util/virnetdevvlan.h
index c6b16ef..93426cc 100644
--- a/src/util/virnetdevvlan.h
+++ b/src/util/virnetdevvlan.h
@@ -17,6 +17,7 @@
*
* Authors:
* Laine Stump <laine(a)redhat.com>
+ * James Robson <jrobson(a)websense.com>
*/
#ifndef __VIR_NETDEV_VLAN_H__
@@ -28,6 +29,8 @@ struct _virNetDevVlan {
bool trunk; /* true if this is a trunk */
int nTags; /* number of tags in array */
unsigned int *tag; /* pointer to array of tags */
+ short int nativeMode; /* 0=off, 1=tagged, 2=untagged */
+ unsigned int nativeTag;
};
void virNetDevVlanClear(virNetDevVlanPtr vlan);
diff --git a/tests/networkxml2xmlin/openvswitch-net.xml
b/tests/networkxml2xmlin/openvswitch-net.xml
index a3d82b1..2f6084d 100644
--- a/tests/networkxml2xmlin/openvswitch-net.xml
+++ b/tests/networkxml2xmlin/openvswitch-net.xml
@@ -21,4 +21,13 @@
<parameters profileid='alice-profile'/>
</virtualport>
</portgroup>
+ <portgroup name='native'>
+ <vlan trunk='yes'>
+ <tag id='123' nativeMode='tagged'/>
+ <tag id='444'/>
+ </vlan>
+ <virtualport>
+ <parameters profileid='native-profile'/>
+ </virtualport>
+ </portgroup>
</network>
diff --git a/tests/networkxml2xmlout/openvswitch-net.xml
b/tests/networkxml2xmlout/openvswitch-net.xml
index a3d82b1..2f6084d 100644
--- a/tests/networkxml2xmlout/openvswitch-net.xml
+++ b/tests/networkxml2xmlout/openvswitch-net.xml
@@ -21,4 +21,13 @@
<parameters profileid='alice-profile'/>
</virtualport>
</portgroup>
+ <portgroup name='native'>
+ <vlan trunk='yes'>
+ <tag id='123' nativeMode='tagged'/>
+ <tag id='444'/>
+ </vlan>
+ <virtualport>
+ <parameters profileid='native-profile'/>
+ </virtualport>
+ </portgroup>
</network>
Protected by Websense Hosted Email Security -- www.websense.com
11 years, 6 months
[libvirt] [PATCH] virsh: lookup interface by name or mac other than one by one
by Guannan Ren
On host without interface eth1, 'virsh iface-dumpxml eth1'
it reports
error: Interface not found: couldn't find interface with MAC address 'eth1'
after fix, it reports
error: Interface not found: couldn't find interface named 'eth1'
---
tools/virsh-interface.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index f75c572..47883ae 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -46,6 +46,7 @@ vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
{
virInterfacePtr iface = NULL;
const char *n = NULL;
+ bool is_name = false;
virCheckFlags(VSH_BYNAME | VSH_BYMAC, NULL);
if (!optname)
@@ -62,14 +63,17 @@ vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
if (name)
*name = n;
+ if (!strchr(n, ':'))
+ is_name = true;
+
/* try it by NAME */
- if (flags & VSH_BYNAME) {
+ if (is_name && (flags & VSH_BYNAME)) {
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface NAME\n",
cmd->def->name, optname);
iface = virInterfaceLookupByName(ctl->conn, n);
- }
+
/* try it by MAC */
- if (!iface && (flags & VSH_BYMAC)) {
+ } else if (!is_name && (flags & VSH_BYMAC)) {
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface MAC\n",
cmd->def->name, optname);
iface = virInterfaceLookupByMACString(ctl->conn, n);
--
1.8.1.4
11 years, 6 months