[libvirt] Remote access form windows - Java bindings
by Gandhiraj Natarajan
Hi
I am developing tool to collect information on XenServer which is on Opensuse 11. I am using libvirt-0.4.6.jar and and jna-3.2.4 jar files.
I tried to connect from Remote system(Windows) to server, but could not get the connection object.
Any configuration needs to be done for remote access ?
conn = new Connect("xen+tcp://192.168.10.22/");
it shows the exception
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library
'virt': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:374)
at com.sun.jna.Native.loadLibrary(Native.java:359)
at org.libvirt.jna.Libvirt.<clinit>(Unknown Source)
at org.libvirt.Connect.<clinit>(Unknown Source)
at LibvirtCon.main(LibvirtCon.java:29)
Help me
Regards
Gandhiraj Natarajan
14 years, 2 months
[libvirt] [PATCH] docs: improve wording for the dev guide
by Justin Clift
Wording tweak suggested by David Jorm, author of the libvirt App Dev Guide.
---
docs/devguide.html.in | 14 +++++++-------
docs/downloads.html.in | 14 +++++++-------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/docs/devguide.html.in b/docs/devguide.html.in
index 409952e..6c51c36 100644
--- a/docs/devguide.html.in
+++ b/docs/devguide.html.in
@@ -4,16 +4,16 @@
<h1>libvirt Application Development Guide</h1>
<p>
- This is both a guide to developing with libvirt, and a useful
- reference document. It is a work in progress, contributed to by the
- members of the libvirt team and being authored by a professional
- author.
+ The guide is both a learning tool for developing with libvirt and an
+ API reference document. It is a work in progress, composed by a
+ professional author from contributions written by members of the
+ libvirt team.
</p>
<p>
- Contributors to this are <b>VERY</b> welcome, so if you'd like to
- get your name in this and demonstrate your virtualisation prowess,
- contributing solidly to the content here will do it. :)
+ Contributions to the guide are <b>VERY</b> welcome. If you'd like to get
+ your name on this and demonstrate your virtualisation prowess, a solid
+ contribution to the content here will do it. :)
</p>
<h2>Browsable online</h2>
diff --git a/docs/downloads.html.in b/docs/downloads.html.in
index 66b99e1..2ce1048 100644
--- a/docs/downloads.html.in
+++ b/docs/downloads.html.in
@@ -49,16 +49,16 @@
<h1>libvirt Application Development Guide</h1>
<p>
- This is both a guide to developing with libvirt, and a useful
- reference document. It is a work in progress, contributed to by the
- members of the libvirt team and being authored by a professional
- author.
+ The guide is both a learning tool for developing with libvirt and an
+ API reference document. It is a work in progress, composed by a
+ professional author from contributions written by members of the
+ libvirt team.
</p>
<p>
- Contributors to this are <b>VERY</b> welcome, so if you'd like to
- get your name in this and demonstrate your virtualisation prowess,
- contributing solidly to the content here will do it. :)
+ Contributions to the guide are <b>VERY</b> welcome. If you'd like to get
+ your name on this and demonstrate your virtualisation prowess, a solid
+ contribution to the content here will do it. :)
</p>
<h2>Downloadable PDF</h2>
--
1.7.2.2
14 years, 2 months
[libvirt] [PATCH] tests: Fix preprocessor indentation
by Jiri Denemark
---
Pushed as obvious to fix make syntax-check failure.
tests/virbuftest.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index d8258fc..db08fc4 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -70,7 +70,7 @@ mymain(int argc ATTRIBUTE_UNUSED,
int ret = 0;
-# define DO_TEST(msg, cb, data) \
+#define DO_TEST(msg, cb, data) \
do { \
struct testInfo info = { data }; \
if (virtTestRun("Buf: " msg, 1, cb, &info) < 0) \
--
1.7.2.2
14 years, 2 months
[libvirt] QEMU interfaces for image streaming and post-copy block migration
by Anthony Liguori
Hi,
We've got copy-on-read and image streaming working in QED and before
going much further, I wanted to bounce some interfaces off of the
libvirt folks to make sure our final interface makes sense.
Here's the basic idea:
Today, you can create images based on base images that are copy on
write. With QED, we also support copy on read which forces a copy from
the backing image on read requests and write requests.
In additional to copy on read, we introduce a notion of streaming a
block device which means that we search for an unallocated region of the
leaf image and force a copy-on-read operation.
The combination of copy-on-read and streaming means that you can start a
guest based on slow storage (like over the network) and bring in blocks
on demand while also having a deterministic mechanism to complete the
transfer.
The interface for copy-on-read is just an option within qemu-img
create. Streaming, on the other hand, requires a bit more thought.
Today, I have a monitor command that does the following:
stream <device> <sector offset>
Which will try to stream the minimal amount of data for a single I/O
operation and then return how many sectors were successfully streamed.
The idea about how to drive this interface is a loop like:
offset = 0;
while offset < image_size:
wait_for_idle_time()
count = stream(device, offset)
offset += count
Obviously, the "wait_for_idle_time()" requires wide system awareness.
The thing I'm not sure about is 1) would libvirt want to expose a
similar stream interface and let management software determine idle time
2) attempt to detect idle time on it's own and provide a higher level
interface. If (2), the question then becomes whether we should try to
do this within qemu and provide libvirt a higher level interface.
A related topic is block migration. Today we support pre-copy migration
which means we transfer the block device and then do a live migration.
Another approach is to do a live migration, and on the source, run a
block server using image streaming on the destination to move the device.
With QED, to implement this one would:
1) launch qemu-nbd on the source while the guest is running
2) create a qed file on the destination with copy-on-read enabled and a
backing file using nbd: to point to the source qemu-nbd
3) run qemu -incoming on the destination with the qed file
4) execute the migration
5) when migration completes, begin streaming on the destination to
complete the copy
6) when the streaming is complete, shut down the qemu-nbd instance on
the source
This is a bit involved and we could potentially automate some of this in
qemu by launching qemu-nbd and providing commands to do some of this.
Again though, I think the question is what type of interfaces would
libvirt prefer? Low level interfaces + recipes on how to do high level
things or higher level interfaces?
Regards,
Anthony Liguori
14 years, 2 months
[libvirt] Release of libvirt-0.8.4
by Daniel Veillard
As planned the release is now available on the server at
ftp://libvirt.org/libvirt/
This is mostly an enhancement and bug fix release, there is less patches
than for usual monthly releases, I guess a number of people had a break
in August :-)
Features:
- various improvements to UML driver (Soren Hansen)
Documentation:
- docs: fix lxc examples (Serge Hallyn)
- docs: mention domain <clock> improvements (Eric Blake)
- docs: fix an incorrect keyword in updated hooks page (Justin Clift)
- docs: significant expansion of custom hook script information (Justin Clift)
Portability
- cygwin: build fix (Stefan Berger)
- build: allow mingw VPATH build (Eric Blake)
- Generate libvirt_qemu.def from libvirt_qemu.syms for MinGW builds (Matthias Bolte)
- Only require XDR when building libvirtd or the remote driver (Matthias Bolte)
- build-sys: fix build when daemon is disabled by not installing libvirtd.8 (Diego Elio Pettenò)
Bug Fixes:
- Fix block statistics with newer versions of Xen (Guido Günther)
- Fix off-by-1 in QEMU boot arg array handling (Daniel P. Berrange)
- bridge: Fix static-only DHCP configuration (Jiri Denemark)
- qemu: qemuMonitorJSONEjectMedia(): Fix arguments' type (Luiz Capitulino)
- qemu: qemuMonitorJSONMigrate(): Fix arguments' type (Luiz Capitulino)
- test: Don't overwrite storage volume target path and key (Matthias Bolte)
- build: Fix permissions of sysconfig files (Jiri Denemark)
- virsh: remove driver check from attach-disk command (Ryan Harper)
- phyp: Bad comparison when checking for existing domain name (Eduardo Otubo)
- esx: Fix esxVI_BuildSelectSet's invalid argument check (Matthias Bolte)
- spec: Fix undefined with_libnl (Jiri Denemark)
- Fix handling of sparse NUMA topologies (Daniel P. Berrange)
- qemu: Check for errors when converting PCI address to string (Jiri Denemark)
- qemu: Fix JSON migrate_set_downtime command (Jiri Denemark)
- uml: fix logic bug in checking reply length (Eric Blake)
- xen: Fix scheduler setting problems (Daniel Veillard)
- nodedev: Free the right pointers when getting WWNs fails (Jiri Denemark)
- nodedev: Fix sysfs paths for vport operations (Dave Allan)
- xen: Fix device count on detach (Daniel Berrange)
- remote: Fix incorrect use of private data field (Daniel Berrange)
- esx: Fix memory leak when looking up an non-existing domain by name (Matthias Bolte)
- Fix up qemu domain save/managed save locking. (Chris Lalancette)
- qemu: Release PCI slot when detaching disk and net devices (Jiri Denemark)
- qemu: Re-reserve all PCI addresses on libvirtd restart (Jiri Denemark)
- Close fd's of persistent tap devices (Soren Hansen)
- Fix tunnelled migration with qemu running as qemu:qemu. (Chris Lalancette)
- Fix valgrind complaints when using kill -SIGHUP on libvirtd (Stefan Berger)
- bridge: Fix potential segfault when preparing dnsmasq arguments (Jiri Denemark)
- Fix return value usage (Doug Goldstein)
- nodeinfo: skip offline CPUs (Eric Blake)
- Do not use boot=on on IDE device (Daniel Veillard)
Improvements:
- virsh: Option for overriding disk type in attach-disk (Jiri Denemark)
- Explicitly pass uml_dir argument to user-mode-linux (Soren Hansen)
- Fix dependancies for remote generated files (Daniel P. Berrange)
- Ensure remote daemon unions are always non-zero length (Daniel P. Berrange)
- Add nwfilter support to UML driver (Soren Hansen)
- esx: Use SessionIsActive when available (Matthias Bolte)
- esx: Fall back to path as key when QueryVirtualDiskUuid isn't available (Matthias Bolte)
- mingw: match recent changes in spec file (Eric Blake)
- Update of localization files (Daniel Veillard)
- esx: Use the VirtualDisk UUID as storage volume key (Matthias Bolte)
- esx: Add .vmdk storage volume creation (Matthias Bolte)
- OpenVZ: add ethernet interface type support (Jean-Baptiste Rouault)
- esx: Rework datastore path parsing and handling (Matthias Bolte)
- esx: Fix generator for string return values (Matthias Bolte)
- build: add some modules (Eric Blake)
- Use global directory as UML's monitorDir for privileged connections (Soren Hansen)
- maint: track moved file (Eric Blake)
- Add tests for Xen's blktap2 implementation (Jim Fehlig)
- Add blktap2 support to xend driver (Jim Fehlig)
- esx: Map the .vmx annotation to the domain XML description (Matthias Bolte)
- esx: Add read-only storage volume access (Matthias Bolte)
- Move libvirt-guests init script and config to tools (Jiri Denemark)
- Support virDomainAttachDevice and virDomainDetachDevice for disks in UML (Soren Hansen)
- Log return value for virConnectGetCapabilities (Daniel P. Berrange)
- Try harder to send RPC error message back to client (Daniel P. Berrange)
- Add explicit warning messages when failing to serialize to XDR (Daniel P. Berrange)
- Allow chardev of type 'file' for UML domains. (Soren Hansen)
- esx: Improve object-by-type lookup performance (Matthias Bolte)
- xen tests: Fix PV-VFB tests with RHEL-5 API (Jiri Denemark)
- xen tests: Fix missing "type ioemu" with rhel5-api (Jiri Denemark)
- nodeinfotest: Print libvirt error on failure (Jiri Denemark)
- xenapi: support xenapi 5.6.0 headers (Eric Blake)
- Add support for -enable-kqemu flag (Daniel P. Berrange)
- esx: Use MD5 sum of mount path as storage pool UUID (Matthias Bolte)
- esx: Make sure dumpxml outputs proper ID for active domains (Matthias Bolte)
- Add actions to virDomainLifecycle enum (Jim Fehlig)
- vbox: add location used in rpmfusion release (Eric Blake)
- storage: add support for Vendor and Model in XML (Patrick Dignan)
- qemu: Fix copy&paste error in warning message (Jiri Denemark)
- nwfilter: extend nwfilter reload support (Stefan Berger)
- esx: Explicitly disable unused floppy devices (Matthias Bolte)
- phyp: Add rudimentary network driver (Eduardo Otubo)
- Make umlConnectTapDevice ask brAddTap for a persistent tap device. (Soren Hansen)
- Make sure all command line arguments get passed to UML (Soren Hansen)
- nwfilter: Discard class D,E IP addresses when sniffing pkts (Stefan Berger)
- nwfilter: serialize execution of scripts with ebtables cmds (Stefan Berger)
- Move the tunnelled migration unix socket to /var/lib/libvirt/qemu (Chris Lalancette)
- qemu: avoid calling the balloon info command if disabled (Daniel Veillard)
- bridge: Add --dhcp-no-override option to dnsmasq (Jiri Denemark)
- esx: Improve VMX file name parsing and formatting (Matthias Bolte)
- esx: Split VMX code into a general and an ESX specific part (Matthias Bolte)
- allow memballoon type of none to desactivate it (Daniel Veillard)
- Add a detailed message when tap device add fails (Doug Goldstein)
- qemu: Hack around asynchronous device_del (Jiri Denemark)
- build-sys: only build the test programs during the check phase. (Diego Elio Pettenò)
- Add "ubd" to the list of disk prefixes (Soren Hansen)
- Extend virSocketParseAddr() to allow a NULL result pointer (Daniel Veillard)
- bootloader_args is named bootargs in xen-xm (Philipp Hahn)
- Fix return value usage (Doug Goldstein)
- qemu: improve error if tun device is missing (Doug Goldstein)
- build: rerun bootstrap if po/Makevars got nuked (Eric Blake)
Cleanups:
- Remove hack to get static binaries in DV environment (Daniel Veillard)
- build: avoid uninitialized variable warning (Eric Blake)
- vbox: factor a large function (Eric Blake)
- lxc: avoid large stacks with veth creation (Eric Blake)
- openvz: use virAsprintf to avoid large stacks (Eric Blake)
- openvz: formatting cleanups (Eric Blake)
- network: use virAsprintf when appropriate (Eric Blake)
- Move hextobin as virHexToBin to util.c (Matthias Bolte)
- Rename qemudShrinkDisks to virDomainDiskRemove and move to domain_conf.c (Soren Hansen)
- xml2sexprtest: Remove graphics from unrelated tests (Jiri Denemark)
- xenapi: Fix compile error in previous commit (Matthias Bolte)
- qemu: Remove code duplication (Jiri Denemark)
- vbox: factor a large function (Eric Blake)
- xenapi: avoid sprintf (Eric Blake)
- storage: avoid s[n]printf (Eric Blake)
- maint: whitespace cleanups (Eric Blake)
- build: delete dead comments (Eric Blake)
- nwfilter: use consistent OOM reporting (Eric Blake)
- build: fix compiler warning (Eric Blake)
- build: fix AppArmor compilation (Jamie Strandboge)
- Avoid unnecessary bootstrap runs in VPATH builds (Jiri Denemark)
- maint: update an email address preference (Eric Blake)
- phyp: refactor phypListDomainsGeneric to eliminate buffer overflow (Eduardo Otubo)
Thanks everybody who helped for the release with patches, bug reports
or documentation !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
14 years, 2 months
[libvirt] Best place to put links to the libvirt App Dev Guide?
by Justin Clift
Hi guys,
Where's the best place in the libvirt.org menu structure, to point
people to the (developing) libvirt App Dev Guide?
My initial thinking is:
a) Have a link to the .pdf in the Downloads section
+
b) Maybe a new top title section like:
Documentation -> "Dev Guide"
With links to the html, html (one big page), and pdf files.
Sound reasonable?
Regards and best wishes,
Justin Clift
14 years, 2 months
[libvirt] [PATCH v3] buf: Fix possible infinite loop in EscapeString, VSnprintf
by Cole Robinson
The current code will go into an infinite loop if the printf generated
string is >= 1000, AND exactly 1 character smaller than the amount of free
space in the buffer. When this happens, we are dropped into the loop body,
but nothing will actually change, because count == (buf->size - buf->use - 1),
and virBufferGrow returns unchanged if count < (buf->size - buf->use)
Fix this by removing the '- 1' bit from 'size'. The *nprintf functions handle
the NULL byte for us anyways, so we shouldn't need to manually accommodate
for it.
Here's a bug where we are actually hitting this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=602772
v2: Eric's improvements: while -> if (), remove extra va_list variable,
make sure we report buffer error if snprintf fails
v3: Add tests/virbuftest which reproduces the infinite loop before this
patch, works correctly after
---
src/util/buf.c | 70 ++++++++++++++++++++++++++++---------------
tests/.gitignore | 1 +
tests/Makefile.am | 7 ++++-
tests/virbuftest.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 137 insertions(+), 25 deletions(-)
create mode 100644 tests/virbuftest.c
diff --git a/src/util/buf.c b/src/util/buf.c
index fc1217b..553e2a0 100644
--- a/src/util/buf.c
+++ b/src/util/buf.c
@@ -224,7 +224,7 @@ void
virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
{
int size, count, grow_size;
- va_list locarg, argptr;
+ va_list argptr;
if ((format == NULL) || (buf == NULL))
return;
@@ -236,27 +236,38 @@ virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
virBufferGrow(buf, 100) < 0)
return;
- size = buf->size - buf->use - 1;
va_start(argptr, format);
- va_copy(locarg, argptr);
- while (((count = vsnprintf(&buf->content[buf->use], size, format,
- locarg)) < 0) || (count >= size - 1)) {
+
+ size = buf->size - buf->use;
+ if ((count = vsnprintf(&buf->content[buf->use],
+ size, format, argptr)) < 0) {
+ buf->error = 1;
+ goto err;
+ }
+
+ /* Grow buffer if necessary and retry */
+ if (count >= size) {
buf->content[buf->use] = 0;
- va_end(locarg);
+ va_end(argptr);
+ va_start(argptr, format);
- grow_size = (count > 1000) ? count : 1000;
+ grow_size = (count + 1 > 1000) ? count + 1 : 1000;
if (virBufferGrow(buf, grow_size) < 0) {
- va_end(argptr);
- return;
+ goto err;
}
- size = buf->size - buf->use - 1;
- va_copy(locarg, argptr);
+ size = buf->size - buf->use;
+ if ((count = vsnprintf(&buf->content[buf->use],
+ size, format, argptr)) < 0) {
+ buf->error = 1;
+ goto err;
+ }
}
- va_end(argptr);
- va_end(locarg);
buf->use += count;
- buf->content[buf->use] = '\0';
+
+err:
+ va_end(argptr);
+ return;
}
/**
@@ -336,23 +347,34 @@ virBufferEscapeString(const virBufferPtr buf, const char *format, const char *st
if ((buf->use >= buf->size) &&
virBufferGrow(buf, 100) < 0) {
- VIR_FREE(escaped);
- return;
+ goto err;
+ }
+
+ size = buf->size - buf->use;
+ if ((count = snprintf(&buf->content[buf->use], size,
+ format, (char *)escaped)) < 0) {
+ buf->error = 1;
+ goto err;
}
- size = buf->size - buf->use - 1;
- while (((count = snprintf(&buf->content[buf->use], size, format,
- (char *)escaped)) < 0) || (count >= size - 1)) {
+ /* Grow buffer if necessary and retry */
+ if (count >= size) {
buf->content[buf->use] = 0;
- grow_size = (count > 1000) ? count : 1000;
+ grow_size = (count + 1 > 1000) ? count + 1 : 1000;
if (virBufferGrow(buf, grow_size) < 0) {
- VIR_FREE(escaped);
- return;
+ goto err;
+ }
+ size = buf->size - buf->use;
+
+ if ((count = snprintf(&buf->content[buf->use], size,
+ format, (char *)escaped)) < 0) {
+ buf->error = 1;
+ goto err;
}
- size = buf->size - buf->use - 1;
}
buf->use += count;
- buf->content[buf->use] = '\0';
+
+err:
VIR_FREE(escaped);
}
diff --git a/tests/.gitignore b/tests/.gitignore
index 3f32939..e7c74c5 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -21,6 +21,7 @@ storagepoolxml2xmltest
nodeinfotest
statstest
qparamtest
+virbuftest
seclabeltest
eventtest
*.exe
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1dc7f66..dd59034 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,7 +73,7 @@ EXTRA_DIST = \
qemuhelpdata
check_PROGRAMS = virshtest conftest \
- nodeinfotest statstest qparamtest
+ nodeinfotest statstest qparamtest virbuftest
if WITH_XEN
check_PROGRAMS += xml2sexprtest sexpr2xmltest \
@@ -151,6 +151,7 @@ TESTS = virshtest \
nodeinfotest \
statstest \
qparamtest \
+ virbuftest \
$(test_scripts)
if WITH_XEN
@@ -352,6 +353,10 @@ qparamtest_SOURCES = \
qparamtest.c testutils.h testutils.c
qparamtest_LDADD = $(LDADDS)
+virbuftest_SOURCES = \
+ virbuftest.c testutils.h testutils.c
+virbuftest_LDADD = $(LDADDS)
+
if WITH_LIBVIRTD
eventtest_SOURCES = \
eventtest.c testutils.h testutils.c ../daemon/event.c
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
new file mode 100644
index 0000000..1cc9410
--- /dev/null
+++ b/tests/virbuftest.c
@@ -0,0 +1,84 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "internal.h"
+#include "util.h"
+#include "testutils.h"
+#include "buf.h"
+#include "memory.h"
+
+#define TEST_ERROR(...) \
+ do { \
+ if (virTestGetDebug()) \
+ fprintf(stderr, __VA_ARGS__); \
+ } while (0)
+
+struct testInfo {
+ int doEscape;
+};
+
+static int testBufInfiniteLoop(const void *data ATTRIBUTE_UNUSED)
+{
+ virBuffer bufinit = VIR_BUFFER_INITIALIZER;
+ virBufferPtr buf = &bufinit;
+ char *addstr = NULL, *bufret = NULL;
+ int ret = -1;
+ const struct testInfo *info = data;
+
+ virBufferAddChar(buf, 'a');
+ if (buf->a != 1002 || buf->b != 1) {
+ TEST_ERROR("Buf was not expected size, size=%d use=%d\n",
+ buf->a, buf->b);
+ goto out;
+ }
+
+ /*
+ * Infinite loop triggers if:
+ * (strlen + 1 > 1000) && (strlen == buf-size - buf-use - 1)
+ */
+ if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0) {
+ goto out;
+ }
+
+ if (info->doEscape)
+ virBufferEscapeString(buf, "%s", addstr);
+ else
+ virBufferVSprintf(buf, "%s", addstr);
+
+ ret = 0;
+out:
+ bufret = virBufferContentAndReset(buf);
+ if (!bufret) {
+ TEST_ERROR("Buffer had error set");
+ ret = -1;
+ }
+
+ VIR_FREE(addstr);
+ VIR_FREE(bufret);
+ return ret;
+}
+
+static int
+mymain(int argc ATTRIBUTE_UNUSED,
+ char **argv ATTRIBUTE_UNUSED)
+{
+ int ret = 0;
+
+
+# define DO_TEST(msg, cb, data) \
+ do { \
+ struct testInfo info = { data }; \
+ if (virtTestRun("Buf: " msg, 1, cb, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
+ DO_TEST("EscapeString infinite loop", testBufInfiniteLoop, 1);
+ DO_TEST("VSprintf infinite loop", testBufInfiniteLoop, 0);
+
+ return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+VIRT_TEST_MAIN(mymain)
--
1.7.2.1
14 years, 2 months
[libvirt] [PATCH] virsh: Option for overriding disk type in attach-disk
by Jiri Denemark
Unless --driver tap|file option was given to attach-disk, virsh would
generate <disk type='block'> XML which might be fine for Xen but not for
other hypervisors. This patch introduces a new option --sourcetype which
can be used to explicitly set the type of disk source. The option
accepts either "file" or "block" types.
---
tools/virsh.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 7bc33d8..57ea618 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8116,6 +8116,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
{"type", VSH_OT_STRING, 0, N_("target device type")},
{"mode", VSH_OT_STRING, 0, N_("mode of device reading and writing")},
{"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
+ {"sourcetype", VSH_OT_STRING, 0, N_("type of source (block|file)")},
{NULL, 0, 0, NULL}
};
@@ -8127,6 +8128,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
int isFile = 0, ret = FALSE;
char *buf = NULL, *tmp = NULL;
unsigned int flags;
+ char *stype;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -8144,10 +8146,16 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
subdriver = vshCommandOptString(cmd, "subdriver", NULL);
type = vshCommandOptString(cmd, "type", NULL);
mode = vshCommandOptString(cmd, "mode", NULL);
+ stype = vshCommandOptString(cmd, "sourcetype", NULL);
- if (driver) {
- if (STREQ(driver, "file") || STREQ(driver, "tap"))
+ if (!stype) {
+ if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
isFile = 1;
+ } else if (STREQ(stype, "file")) {
+ isFile = 1;
+ } else if (STRNEQ(stype, "block")) {
+ vshError(ctl, _("Unknown source type: '%s'"), stype);
+ goto cleanup;
}
if (mode) {
--
1.7.2.2
14 years, 2 months
[libvirt] [PATCH] bridge: Fix static-only DHCP configuration
by Jiri Denemark
For static-only DHCP, i.e. with no <range> but at least one <host>
element within <dhcp> element, we have to add "--dhcp-range IP,static"
option to dnsmasq to actually enable the service. Without this option,
dnsmasq will not respond to DHCP requests.
---
src/network/bridge_driver.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d6d3068..01d2171 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -394,6 +394,16 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
int nbleases = 0;
char *pidfileArg;
char buf[1024];
+ unsigned int ranges;
+
+ /*
+ * For static-only DHCP, i.e. with no range but at least one host element,
+ * we have to add a special --dhcp-range option to enable the service in
+ * dnsmasq.
+ */
+ ranges = network->def->nranges;
+ if (!ranges && network->def->nhosts)
+ ranges = 1;
/*
* NB, be careful about syntax for dnsmasq options in long format
@@ -424,11 +434,11 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
/*2 + *//* --interface virbr0 */
2 + /* --except-interface lo */
2 + /* --listen-address 10.0.0.1 */
- (2 * network->def->nranges) + /* --dhcp-range 10.0.0.2,10.0.0.254 */
+ (2 * ranges) + /* --dhcp-range 10.0.0.2,10.0.0.254 */
/* --dhcp-lease-max=xxx if needed */
(network->def->nranges ? 1 : 0) +
/* --dhcp-no-override if needed */
- (network->def->nranges ? 1 : 0) +
+ (ranges ? 1 : 0) +
/* --dhcp-hostsfile=/var/lib/dnsmasq/$NAME.hostsfile */
(network->def->nhosts > 0 ? 1 : 0) +
/* --enable-tftp --tftp-root /srv/tftp */
@@ -496,12 +506,22 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
nbleases += network->def->ranges[r].size;
}
+ if (!network->def->nranges && network->def->nhosts) {
+ snprintf(buf, sizeof(buf), "%s,static",
+ network->def->ipAddress);
+
+ APPEND_ARG(*argv, i++, "--dhcp-range");
+ APPEND_ARG(*argv, i++, buf);
+ }
+
if (network->def->nranges > 0) {
snprintf(buf, sizeof(buf), "--dhcp-lease-max=%d", nbleases);
APPEND_ARG(*argv, i++, buf);
- APPEND_ARG(*argv, i++, "--dhcp-no-override");
}
+ if (ranges)
+ APPEND_ARG(*argv, i++, "--dhcp-no-override");
+
if (network->def->nhosts > 0) {
dnsmasqContext *dctx = dnsmasqContextNew(network->def->name, DNSMASQ_STATE_DIR);
char *hostsfileArg;
--
1.7.2.2
14 years, 2 months