[libvirt] [PATCH] mingw32-libvirt.spec: bring up to date
by Eric Blake
Right now, mingw32-portablexdr is not available in Fedora, but is
present in fedora-mingw.git. With that package, plus
redhat-rpm-config and this patch, it is once again possible to build
mingw32-libvirt from a Fedora 12 host.
* mingw32-libvirt.spec.in (__debug_install_post): Override.
(%files): Mention recent additions.
---
The __debug_install_post trick is something that Richard Jones
taught me while figuring out how to get mingw32-portablexdr.
Also, during that effort, we discovered this bug in rpm:
https://bugzilla.redhat.com/show_bug.cgi?id=587818
you have to have redhat-rpm-config installed to work around it.
mingw32-libvirt.spec.in | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index 867a849..fc90203 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -3,6 +3,7 @@
%define _use_internal_dependency_generator 0
%define __find_requires %{_mingw32_findrequires}
%define __find_provides %{_mingw32_findprovides}
+%define __debug_install_post %{_mingw32_debug_install_post}
Name: mingw32-libvirt
Version: @VERSION@
@@ -30,6 +31,7 @@ BuildRequires: gettext
BuildArch: noarch
+%{?_mingw32_debug_package}
%description
MinGW Windows libvirt virtualization library.
@@ -95,9 +97,12 @@ rm -rf $RPM_BUILD_ROOT
%{_mingw32_datadir}/libvirt/schemas/nodedev.rng
%{_mingw32_datadir}/libvirt/schemas/capability.rng
%{_mingw32_datadir}/libvirt/schemas/interface.rng
+%{_mingw32_datadir}/libvirt/schemas/nwfilter.rng
%{_mingw32_datadir}/libvirt/schemas/secret.rng
%{_mingw32_datadir}/libvirt/schemas/storageencryption.rng
+%{_mingw32_datadir}/libvirt/cpu_map.xml
+
%{_mingw32_datadir}/locale/*/LC_MESSAGES/libvirt.mo
%dir %{_mingw32_includedir}/libvirt
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] Fix pthread related link error for virt-aa-helper
by Matthias Bolte
Link virt-aa-helper explicitly with pthread. This is at least
required on Ubuntu 10.04.
---
I just pushed this one, as it qualifies as trivial compile fix.
src/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 2025208..0da30bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1002,7 +1002,7 @@ libexec_PROGRAMS += virt-aa-helper
virt_aa_helper_SOURCES = $(SECURITY_DRIVER_APPARMOR_HELPER_SOURCES)
-virt_aa_helper_LDFLAGS = $(WARN_CFLAGS)
+virt_aa_helper_LDFLAGS = $(WARN_CFLAGS) $(LIB_PTHREAD)
virt_aa_helper_LDADD = \
$(WARN_CFLAGS) \
$(LIBXML_LIBS) \
--
1.7.0.4
14 years, 6 months
[libvirt] [Reminder] KVM Forum 2010: Call for Papers
by KVM Forum 2010 Program Committee
Just a reminder...The submission deadline is in one week.
thanks,
-KVM Forum 2010 Program Commitee
--
=================================================================
CALL FOR PAPERS
KVM Forum 2010
=================================================================
DESCRIPTION
The KVM Forum is back! After a break last year we're proud to present
this year's gathering around KVM again. The idea is to have everyone
involved with KVM development come together to talk about the future
and current state of KVM, teaching everyone some pieces of the puzzle
they might be missing without.
So if you're a KVM developer, mark the dates in your calendar! If
possible, also submit a talk -- we're interested in a wide variety of
KVM topics, so don't hesitate to propose a talk on your work.
If you're not a KVM developer, please read on nevertheless (or jump to
END USER COLLABORATION).
DATES / LOCATION
Conference: August 9 - 10, 2010
Location: Renaissance Boston Waterfront in Boston, MA
Abstracts due: May 14th, 2010
Notification: May 28th, 2010
Yes, we're colocated with LinuxCon. Tickets for the KVM Forum also count
for LinuxCon.
http://events.linuxfoundation.org/component/registrationpro/?func=details...
PROCESS
At first check if it's before May 14th. If you're past that date, you're
out of luck. Now try to think hard and come up with a great idea that
you could talk about. Once you have that set, we need you to write up
a short abstract (~150 words) on it. In your submission please note
how long your talk will take. Slots vary in length up to one hour.
Also include in your proposal the proposal type -- one of: technical talk,
breakout session, or end-user talk. Add that information to the abstract
and submit it at the following URL:
http://events.linuxfoundation.org/cfp/cfp-add
Now, wait until May 24th. You will receive a notification on whether
your talk was accepted or not.
SCOPE OF TALKS
We have a list of suggested presentation topics below. These suggestions
are just for guidance, please feel free to submit a proposal on any
of these or related topics. In general, the more it's about backend
infrastructure, the better.
KVM
- Scaling and performance
- Nested virtualization
- I/O improvements
- Driver domains
- Time keeping
- Memory management (page sharing, swapping, huge pages, etc)
- Fault tolerance
- VEPA, vswitch
Embedded KVM
- KVM on ARM, PPC, MIPS, ...?
- Real-time requirements host/guest
- Device pass-through w/o iommu
- Custom device/platform models
QEMU
- Device model improvements
- New devices
- Security model
- Scaling and performance
- Desktop virtualization
- Increasing robustness
- Management interfaces
- QMP protocol and implementation
- Live migration
Virtio
- Speeding up existing devices
- Vhost
- Alternatives
- Using virtio in non-kvm environments
- Virtio on non-Linux
Management infrastructure
- Libvirt
- Kvm autotest
- Easy networking
- Qemud
BREAKOUT SESSION
We will reserve some time each day to break out for working sessions.
These sessions will be less formal than a presentation and more focused
on developing a solution to some real development issue. If you are
interested in getting developers together to hack on some code, submit
your proposal and just make it clear it's a breakout session proposal.
END-USER COLLABORATION
One of the big challenges as developers is to know what, where and how
people actually use our software. To solve this issue at least a little,
there will be a few slots reserved for end users talking about their
deployments, problems and achievements.
So if you have a KVM based deployment running in production or are about
to roll out one, please also submit a talk (see PROCESS), and simply
mark it asn an end-user collaboration proposal. We would love to have
an open discussion of fields where KVM/Qemu can still improve and you
would have the unique chance to steer that process!
Keep in mind that most of the Forum will be focused on development though,
so we suggest you also come with a good portion of technical interest :-).
And of course, no product marketing please! The purpose is to engage
with KVM developers.
LIGHTNING TALKS
In addition to submitted talks we will also have some room for lightning
talks. So if you have something you think might be done until the KVM
Forum, but you're not sure you could fill 15 minutes with it. Or if you
don't know if you'll make it until there, just keep in mind that you
will still get the chance to talk about it. Lightning talk submissions
and scheduling will be handled on-site at KVM Forum.
Thank you for your interest in KVM. We're looking forward to your
submissions and seeing you at the KVM Forum 2010 in August! Now, start
thinking about that talk you want to give.
Thanks,
your KVM Forum 2010 Program Commitee
Alexander Graf, Novell
Anthony Liguori, IBM
Avi Kivity, Red Hat
Chris Wright, Red Hat
Dor Laor, Red Hat
Jan Kiszka, Siemens
Please contact us with any questions or comments.
KVM-Forum-2010-PC(a)redhat.com
14 years, 6 months
[libvirt] [PATCH] qemu: Fix warning about a non-literal format string
by Matthias Bolte
---
I just pushed this one, as it qualifies as trivial compile fix.
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 92dc22d..bb1079e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7968,7 +7968,7 @@ static int qemudDomainDetachSCSIDiskDevice(struct qemud_driver *driver,
}
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
- qemuReportError(VIR_ERR_OPERATION_FAILED,
+ qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Underlying qemu does not support SCSI disk removal"));
goto cleanup;
}
--
1.7.0.4
14 years, 6 months
[libvirt] [PATCH] avoid link error in tests using libvirt_util; due to pthread_sigmask
by Jim Meyering
Without this patch, linking the test programs fails like this:
/usr/bin/ld: ../src/.libs/libvirt_test.a(libvirt_util_la-util.o): undefined reference to symbol 'pthread_sigmask@(a)GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_sigmask@(a)GLIBC_2.2.5' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[3]: *** [nodeinfotest] Error 1
>From ae53113ddf09846cc01ec0f5e6e65a25991b1bfa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 7 May 2010 16:23:44 +0200
Subject: [PATCH] avoid link error in tests using libvirt_util; due to pthread_sigmask
* src/Makefile.am (libvirt_util_la_LDFLAGS): Add $(LIB_PTHREAD),
required, now that we're using gnulib's pthread module.
2010-05-07 Jim Meyering <meyering(a)redhat.com>
---
src/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7182da1..937ee84 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -378,7 +378,7 @@ libvirt_la_LIBADD = libvirt_util.la
libvirt_util_la_SOURCES = \
$(UTIL_SOURCES)
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS)
-libvirt_util_la_LDFLAGS = $(CAPNG_LIBS) $(YAJL_LIBS)
+libvirt_util_la_LDFLAGS = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIB_PTHREAD)
noinst_LTLIBRARIES += libvirt_conf.la
--
1.7.1.166.gf2086
14 years, 6 months
[libvirt] [PATCH] Remove unused nwfilter field from struct remote_error
by Matthew Booth
Change 965466c1 added a new field to struct remote_error, which broke the RPC
protocol. Fortunately the new field is unused, so this change simply removes it
again.
* src/remote/remote_protocol.(c|h|x): Remove remote_nwfilter from struct
remote_error
---
src/remote/remote_protocol.c | 2 --
src/remote/remote_protocol.h | 1 -
src/remote/remote_protocol.x | 1 -
3 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 187281d..972bf52 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -227,8 +227,6 @@ xdr_remote_error (XDR *xdrs, remote_error *objp)
return FALSE;
if (!xdr_remote_network (xdrs, &objp->net))
return FALSE;
- if (!xdr_remote_nwfilter (xdrs, &objp->nwfilter))
- return FALSE;
return TRUE;
}
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 6f01da7..a600af6 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -143,7 +143,6 @@ struct remote_error {
int int1;
int int2;
remote_network net;
- remote_nwfilter nwfilter;
};
typedef struct remote_error remote_error;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 8000ee0..1ce488c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -266,7 +266,6 @@ struct remote_error {
int int1;
int int2;
remote_network net;
- remote_nwfilter nwfilter;
};
/* Authentication types available thus far.... */
--
1.6.6.1
14 years, 6 months
[libvirt] [TCK PATCH] block devices: allow specification of size for safety
by Eric Blake
I was getting failures of domain/103-blockdev-save-restore.t when
connecting as qemu:///session, since my uid could stat /dev/sdb
but not open it. That test now skips for unprivileged users, as well
as adds a layer of sanity checking against expected size to avoid
trashing the wrong device.
* conf/default.cfg (host_block_devices): Document optional size.
* lib/Sys/Virt/TCK.pm (get_host_block_device): If optional size is
supplied, skip a device that does not match. Also, avoid devices
that can't be opened.
---
Go easy on me - I'm not that fluent in perl (yet); if there's
a better way to do the sanity check, I'm all ears.
conf/default.cfg | 8 ++++++++
lib/Sys/Virt/TCK.pm | 14 +++++++++++++-
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/conf/default.cfg b/conf/default.cfg
index 01f438c..12c05b7 100644
--- a/conf/default.cfg
+++ b/conf/default.cfg
@@ -134,5 +134,13 @@ host_pci_devices = (
# the test suite itself needs to create partitions.
# The disks should be at *least* 512 MB in size
host_block_devices = (
+# Each block device is either a raw path
# /dev/vdb
+# or a path plus size in 1k blocks, as in /proc/partitions, to avoid
+# trashing the wrong device
+# {
+# path = /dev/sdb
+# size = 989184
+# }
+# Can list more than on block device if many are available
)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index 9cdef09..fc325a3 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -33,6 +33,7 @@ use IO::Uncompress::Gunzip qw(gunzip);
use IO::Uncompress::Bunzip2 qw(bunzip2);
use XML::XPath;
use Carp qw(cluck carp);
+use Fcntl qw(O_RDONLY SEEK_END);
use Test::Builder;
use Sub::Uplevel qw(uplevel);
@@ -833,7 +834,18 @@ sub get_host_block_device {
my $self = shift;
my $devindex = @_ ? shift : 0;
- return $self->config("host_block_devices/[$devindex]", undef);
+ my $device = $self->config("host_block_devices/[$devindex]/path", undef);
+ my $size = $self->config("host_block_devices/[$devindex]/size", 0);
+
+ if (!defined $device) {
+ $device = $self->config("host_block_devices/[$devindex]", undef);
+ }
+ if ($size) {
+ sysopen(BLK, "$device", O_RDONLY) or return undef;
+ return undef unless sysseek(BLK, 0, SEEK_END) == $size * 1024;
+ close(BLK);
+ }
+ return $device;
}
1;
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] Add support for NIC hotplug using netdev_add in QEMU
by Daniel P. Berrange
QEMU is gaining a new monitor command netdev_add for hotplugging
NICs using the netdev backend code. We already support this on
the command this, though it is disabled. This adds support for
hotplug too, also to remain disabled until 0.13 QEMU is released
* src/qemu/qemu_driver.c: Support netdev hotplug for NICs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
support for netdev_add and netdev_remove commands
---
src/qemu/qemu_driver.c | 58 +++++++++++---
src/qemu/qemu_monitor.c | 31 ++++++++
src/qemu/qemu_monitor.h | 6 ++
src/qemu/qemu_monitor_json.c | 175 ++++++++++++++++++++++++++++--------------
src/qemu/qemu_monitor_json.h | 6 ++
src/qemu/qemu_monitor_text.c | 58 ++++++++++++++
src/qemu/qemu_monitor_text.h | 6 ++
7 files changed, 269 insertions(+), 71 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b8a021d..d5a0c68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7273,12 +7273,17 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0)
goto cleanup;
- vlan = qemuDomainNetVLAN(net);
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ vlan = -1;
+ } else {
+ vlan = qemuDomainNetVLAN(net);
- if (vlan < 0) {
- qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("Unable to attach network devices without vlan"));
- goto cleanup;
+ if (vlan < 0) {
+ qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("Unable to attach network devices without vlan"));
+ goto cleanup;
+ }
}
if (tapfd != -1) {
@@ -7306,9 +7311,17 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorAddHostNetwork(priv->mon, netstr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto try_tapfd_close;
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ if (qemuMonitorAddNetdev(priv->mon, netstr) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ goto try_tapfd_close;
+ }
+ } else {
+ if (qemuMonitorAddHostNetwork(priv->mon, netstr) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ goto try_tapfd_close;
+ }
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -7365,7 +7378,20 @@ cleanup:
try_remove:
if (vlan < 0) {
- VIR_WARN0(_("Unable to remove network backend"));
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ char *netdev_name;
+ if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0)
+ goto no_memory;
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ if (qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0)
+ VIR_WARN(_("Failed to remove network backend for netdev %s"),
+ netdev_name);
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ VIR_FREE(netdev_name);
+ } else {
+ VIR_WARN0(_("Unable to remove network backend"));
+ }
} else {
char *hostnet_name;
if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0)
@@ -8197,9 +8223,17 @@ qemudDomainDetachNetDevice(struct qemud_driver *driver,
}
}
- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
+ if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ goto cleanup;
+ }
+ } else {
+ if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ goto cleanup;
+ }
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 5eb05d3..4a8ee9d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1437,6 +1437,37 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
return ret;
}
+
+int qemuMonitorAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr)
+{
+ int ret;
+ DEBUG("mon=%p, fd=%d netdevstr=%s",
+ mon, mon->fd, netdevstr);
+
+ if (mon->json)
+ ret = qemuMonitorJSONAddNetdev(mon, netdevstr);
+ else
+ ret = qemuMonitorTextAddNetdev(mon, netdevstr);
+ return ret;
+}
+
+
+int qemuMonitorRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias)
+{
+ int ret;
+ DEBUG("mon=%p, fd=%d alias=%s",
+ mon, mon->fd, alias);
+
+ if (mon->json)
+ ret = qemuMonitorJSONRemoveNetdev(mon, alias);
+ else
+ ret = qemuMonitorTextRemoveNetdev(mon, alias);
+ return ret;
+}
+
+
int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
virHashTablePtr paths)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 4e3c4e8..0eeb563 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -325,6 +325,12 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
int vlan,
const char *netname);
+int qemuMonitorAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr);
+
+int qemuMonitorRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias);
+
int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
virHashTablePtr paths);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8249b99..79daaf3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -457,6 +457,65 @@ error:
}
+static void
+qemuFreeKeywords(int nkeywords, char **keywords, char **values)
+{
+ int i;
+ for (i = 0 ; i < nkeywords ; i++) {
+ VIR_FREE(keywords[i]);
+ VIR_FREE(values[i]);
+ }
+ VIR_FREE(keywords);
+ VIR_FREE(values);
+}
+
+static virJSONValuePtr
+qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
+{
+ virJSONValuePtr ret = NULL;
+ char **keywords = NULL;
+ char **values = NULL;
+ int nkeywords = 0;
+ int i;
+
+ if (!(ret = virJSONValueNewObject()))
+ goto no_memory;
+
+ nkeywords = qemuParseKeywords(str, &keywords, &values, 1);
+
+ if (nkeywords < 0)
+ goto error;
+
+ for (i = 0 ; i < nkeywords ; i++) {
+ if (values[i] == NULL) {
+ if (i != 0) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected empty keyword in %s"), str);
+ goto error;
+ } else {
+ /* This 3rd arg isn't a typo - the way the parser works is
+ * that the value ended up in the keyword field */
+ if (virJSONValueObjectAppendString(ret, firstkeyword, keywords[i]) < 0)
+ goto no_memory;
+ }
+ } else {
+ if (virJSONValueObjectAppendString(ret, keywords[i], values[i]) < 0)
+ goto no_memory;
+ }
+ }
+
+ qemuFreeKeywords(nkeywords, keywords, values);
+ return ret;
+
+no_memory:
+ virReportOOMError();
+error:
+ qemuFreeKeywords(nkeywords, keywords, values);
+ virJSONValueFree(ret);
+ return NULL;
+}
+
+
static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
{
qemuMonitorEmitShutdown(mon);
@@ -1830,6 +1889,63 @@ int qemuMonitorJSONRemoveHostNetwork(qemuMonitorPtr mon,
}
+int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr)
+{
+ int ret = -1;
+ virJSONValuePtr cmd = NULL;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr args = NULL;
+
+ cmd = qemuMonitorJSONMakeCommand("netdev_add", NULL);
+ if (!cmd)
+ return -1;
+
+ args = qemuMonitorJSONKeywordStringToJSON(netdevstr, "type");
+ if (!args)
+ goto cleanup;
+
+ if (virJSONValueObjectAppend(cmd, "arguments", args) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ args = NULL; /* obj owns reference to args now */
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+cleanup:
+ virJSONValueFree(args);
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
+int qemuMonitorJSONRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias)
+{
+ int ret;
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("netdev_del",
+ "s:id", alias,
+ NULL);
+ virJSONValuePtr reply = NULL;
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
/*
* Example return data
*
@@ -2040,65 +2156,6 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
}
-static void
-qemuFreeKeywords(int nkeywords, char **keywords, char **values)
-{
- int i;
- for (i = 0 ; i < nkeywords ; i++) {
- VIR_FREE(keywords[i]);
- VIR_FREE(values[i]);
- }
- VIR_FREE(keywords);
- VIR_FREE(values);
-}
-
-static virJSONValuePtr
-qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
-{
- virJSONValuePtr ret = NULL;
- char **keywords = NULL;
- char **values = NULL;
- int nkeywords = 0;
- int i;
-
- if (!(ret = virJSONValueNewObject()))
- goto no_memory;
-
- nkeywords = qemuParseKeywords(str, &keywords, &values, 1);
-
- if (nkeywords < 0)
- goto error;
-
- for (i = 0 ; i < nkeywords ; i++) {
- if (values[i] == NULL) {
- if (i != 0) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected empty keyword in %s"), str);
- goto error;
- } else {
- /* This 3rd arg isn't a typo - the way the parser works is
- * that the value ended up in the keyword field */
- if (virJSONValueObjectAppendString(ret, firstkeyword, keywords[i]) < 0)
- goto no_memory;
- }
- } else {
- if (virJSONValueObjectAppendString(ret, keywords[i], values[i]) < 0)
- goto no_memory;
- }
- }
-
- qemuFreeKeywords(nkeywords, keywords, values);
- return ret;
-
-no_memory:
- virReportOOMError();
-error:
- qemuFreeKeywords(nkeywords, keywords, values);
- virJSONValueFree(ret);
- return NULL;
-}
-
-
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
const char *devicestr)
{
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 5cfbe6c..4dcb3e0 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -159,6 +159,12 @@ int qemuMonitorJSONRemoveHostNetwork(qemuMonitorPtr mon,
int vlan,
const char *netname);
+int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr);
+
+int qemuMonitorJSONRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias);
+
int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
virHashTablePtr paths);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 3f917bf..faa144d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1813,6 +1813,64 @@ cleanup:
}
+int qemuMonitorTextAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr)
+{
+ char *cmd;
+ char *reply = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&cmd, "netdev_add %s", netdevstr) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("failed to add netdev with '%s'"), cmd);
+ goto cleanup;
+ }
+
+ /* XXX error messages here ? */
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cmd);
+ VIR_FREE(reply);
+ return ret;
+}
+
+
+int qemuMonitorTextRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias)
+{
+ char *cmd;
+ char *reply = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&cmd, "netdev_del %s", alias) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("failed to remove netdev in qemu with '%s'"), cmd);
+ goto cleanup;
+ }
+
+ /* XXX error messages here ? */
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cmd);
+ VIR_FREE(reply);
+ return ret;
+}
+
+
/* Parse the output of "info chardev" and return a hash of pty paths.
*
* Output is:
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 23c3a45..25be828 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -154,6 +154,12 @@ int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon,
int vlan,
const char *netname);
+int qemuMonitorTextAddNetdev(qemuMonitorPtr mon,
+ const char *netdevstr);
+
+int qemuMonitorTextRemoveNetdev(qemuMonitorPtr mon,
+ const char *alias);
+
int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
virHashTablePtr paths);
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] Add env variable for debugging gnutls usage
by Daniel P. Berrange
Allow debugging of GNUTLS interactions by setting
LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh
* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
enable gnutls debugging
---
src/remote/remote_driver.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 72cf292..9e90e5c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1138,16 +1138,29 @@ check_cert_file(const char *type, const char *file)
}
+static void remote_debug_gnutls_log(int level, const char* str) {
+ DEBUG("%d %s", level, str);
+}
+
static int
initialize_gnutls(void)
{
static int initialized = 0;
int err;
+ char *gnudebug;
if (initialized) return 0;
gnutls_global_init ();
+ if ((gnudebug = getenv("LIBVIRT_GNUTLS_DEBUG")) != NULL) {
+ int val;
+ if (virStrToLong_i(gnudebug, NULL, 10, &val) < 0)
+ val = 10;
+ gnutls_global_set_log_level(val);
+ gnutls_global_set_log_function(remote_debug_gnutls_log);
+ }
+
/* X509 stuff */
err = gnutls_certificate_allocate_credentials (&x509_cred);
if (err) {
--
1.6.6.1
14 years, 6 months