[libvirt] [PATCH] build: fix 'make dist' without dtrace
by Eric Blake
probes.h can only be generated on Linux, and then only with dtrace
installed. If it is part of the tarball, then either 'make dist'
will fail if you don't have that setup, or we would have to start
keeping probes.h in libvirt.git. Since we only need it to be
generated when dtrace is in use, it's better to avoid shipping
it in the first place, and avoid tracking it in git.
Meanwhile, there is a build dependency - since the RPC code is
generated, it can be built early; but when dtrace is enabled, we
must ensure probes.h is built even earlier. Commit 1afcfbdd tried
to fix this, but did so in a way that added probes.h into the
tarball, and broke VPATH as well. Commit ecbca767 fixed VPATH,
but didn't fix the more fundamental problem. This patch solves
the issue by adding a dependency instead.
Tested with 'make dist' in a clean VPATH builds, for both
'./configure --without-dtrace' and './configure --with-dtrace';
all configurations were able to correctly build a tarball, and
the dtrace configuration no longer sticks probes.h in the tarball.
* src/Makefile.am (REMOTE_DRIVER_GENERATED): Don't ship probes.h;
rather, make it a dependency.
---
Pushing under the build-breaker rule, since I reproduced a
failure with './configure --without-dtrace && make dist' without
this patch.
src/Makefile.am | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c98397..93bf54c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -202,11 +202,6 @@ REMOTE_DRIVER_GENERATED = \
$(srcdir)/remote/qemu_protocol.h \
$(srcdir)/remote/qemu_client_bodies.h
-# The remote RPC driver needs probes.h
-if WITH_DTRACE
-REMOTE_DRIVER_GENERATED += probes.h
-endif
-
REMOTE_PROTOCOL = $(srcdir)/remote/remote_protocol.x
QEMU_PROTOCOL = $(srcdir)/remote/qemu_protocol.x
REMOTE_DRIVER_PROTOCOL = $(REMOTE_PROTOCOL) $(QEMU_PROTOCOL)
@@ -646,7 +641,6 @@ libvirt_driver_remote_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES)
-
$(srcdir)/remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED)
endif WITH_REMOTE
@@ -1283,6 +1277,9 @@ if WITH_DTRACE
libvirt_la_BUILT_LIBADD += probes.o
libvirt_la_DEPENDENCIES += probes.o
nodist_libvirt_la_SOURCES = probes.h
+if WITH_REMOTE
+$(REMOTE_DRIVER_GENERATED): probes.h
+endif WITH_REMOTE
BUILT_SOURCES += probes.h libvirt_probes.stp libvirt_functions.stp
--
1.7.7.3
13 years
[libvirt] [PATCH] Don't use undocumented __isleap macro
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Pushing under build-breaker (mingw32) rule
The glibc time.h header has an undocumented __isleap macro
that we are using. Since it is undocumented & does not appear
on any other OS, stop using it and just define the macro in
libvirt code instead.
* src/util/virtime.c: Remove __isleap usage
---
src/util/virtime.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/util/virtime.c b/src/util/virtime.c
index 25c2317..92b6cdd 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -113,6 +113,9 @@ const unsigned short int __mon_yday[2][13] = {
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
+#define is_leap_year(y) \
+ ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
+
/**
* virTimeFieldsThenRaw:
* @when: the time to convert in milliseconds
@@ -152,7 +155,7 @@ int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
fields->tm_wday += 7;
y = 1970;
- while (days < 0 || days >= (__isleap (y) ? 366 : 365)) {
+ while (days < 0 || days >= (is_leap_year(y) ? 366 : 365)) {
/* Guess a corrected year, assuming 365 days per year. */
long int yg = y + days / 365 - (days % 365 < 0);
@@ -165,7 +168,7 @@ int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
fields->tm_year = y - 1900;
fields->tm_yday = days;
- ip = __mon_yday[__isleap(y)];
+ ip = __mon_yday[is_leap_year(y)];
for (y = 11; days < (long int) ip[y]; --y)
continue;
days -= ip[y];
--
1.7.6.4
13 years
[libvirt] [PATCH libvirt-glib 00/15] More misc improvements
by Daniel P. Berrange
This series has three functional improvements
- Support for <console>
- Support for <memballoon>
- Support containers
The rest of it is a series of code style cleanups. Finally
it adds the 'make syntax-check' capability from gnulib to
keep code style clean hereafter
13 years
[libvirt] [PATCH] Fix a logic error for setting block I/O
by Lei Li
Fix a logic error, the initial value of ret = -1, if just set --config,
it will goto endjob directly without doing its really job here.
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ed90c66..8ea6f48 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11234,8 +11234,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info);
qemuDomainObjExitMonitorWithDriver(driver, vm);
}
- if (ret < 0)
- goto endjob;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
sa_assert(persistentDef && idx >= 0);
--
1.7.1
13 years
[libvirt] libvirt-php 0.4.5 and php 5.4
by Remi Collet
Hi,
I'm working on updating PHP to 5.4.0 (probably a fedora 17 feature).
libvirt 0.4.5 doesn't build because function_entry have been removed
See http://news.php.net/php.pecl.dev/7123
Fix is trivial :
s/function_entry/zend_function_entry/
Attcached patch solves this issue and also fixes a lot of compiler
warning (unused variable, unset, ...)
There is still a lot of warning... (most are trivial to fix)
I Hope this helps.
Remi.
P.S. Here is the full log (with -Wall)
Making all in src
make[3]: Entering directory `/dev/shm/libvirt-php-0.4.5/src'
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -I/usr/include/php -I/usr/include/php/main
-I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
-I/usr/include/php/ext/date/lib -c -o libvirt-php.o libvirt-php.c
-I/usr/include/libxml2 -DHAVE_CONFIG_H
rm -f *.o
libvirt-php.c: In function 'zif_libvirt_domain_send_keys':
libvirt-php.c:3002:2: warning: pointer targets in passing argument 3 of
'vnc_send_keys' differ in signedness [-Wpointer-sign]
libvirt-php.h:200:5: note: expected 'unsigned char *' but argument is of
type 'char *'
libvirt-php.c: In function 'zif_libvirt_image_create':
libvirt-php.c:1674:8: warning: ignoring return value of 'system',
declared with attribute warn_unused_result [-Wunused-result]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -c -o vncfunc.o vncfunc.c -I/usr/include/php
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib
-I/usr/include/libxml2 -DHAVE_CONFIG_H
vncfunc.c: In function 'vnc_parse_fb_params':
vncfunc.c:178:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:178:2: warning: pointer targets in passing argument 1 of
'__strdup' differ in signedness [-Wpointer-sign]
/usr/include/bits/string2.h:1303:14: note: expected 'const char *' but
argument is of type 'unsigned char *'
vncfunc.c:178:21: warning: pointer targets in assignment differ in
signedness [-Wpointer-sign]
vncfunc.c:141:17: warning: unused variable 'name' [-Wunused-variable]
vncfunc.c:139:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_key':
vncfunc.c:205:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_connect':
vncfunc.c:438:2: warning: implicit declaration of function
'connect_socket' [-Wimplicit-function-declaration]
vncfunc.c: In function 'vnc_get_dimensions':
vncfunc.c:511:2: warning: pointer targets in passing argument 1 of
'vnc_parse_fb_params' differ in signedness [-Wpointer-sign]
vncfunc.c:137:17: note: expected 'unsigned char *' but argument is of
type 'char *'
vncfunc.c:525:2: warning: implicit declaration of function
'socket_has_data' [-Wimplicit-function-declaration]
vncfunc.c:526:3: warning: implicit declaration of function 'socket_read'
[-Wimplicit-function-declaration]
vncfunc.c:484:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:484:9: warning: unused variable 'skip_next' [-Wunused-variable]
vncfunc.c:484:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_keys':
vncfunc.c:569:2: warning: pointer targets in passing argument 1 of
'vnc_parse_fb_params' differ in signedness [-Wpointer-sign]
vncfunc.c:137:17: note: expected 'unsigned char *' but argument is of
type 'char *'
vncfunc.c:572:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:572:2: warning: format '%d' expects argument of type 'int',
but argument 5 has type 'size_t' [-Wformat]
vncfunc.c:573:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:580:3: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:600:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:600:2: warning: format '%d' expects argument of type 'int',
but argument 4 has type 'size_t' [-Wformat]
vncfunc.c:547:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_pointer_event':
vncfunc.c:627:16: warning: unused variable 'end' [-Wunused-variable]
vncfunc.c:625:26: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:625:22: warning: unused variable 'ok' [-Wunused-variable]
vncfunc.c:625:19: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c:625:11: warning: unused variable 'j' [-Wunused-variable]
vncfunc.c: In function 'vnc_refresh_screen':
vncfunc.c:697:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:697:9: warning: unused variable 'skip_next' [-Wunused-variable]
vncfunc.c:697:6: warning: unused variable 'i' [-Wunused-variable]
In file included from /usr/include/string.h:642:0,
from /usr/include/php/main/../main/php_config.h:2440,
from /usr/include/php/Zend/zend_config.h:1,
from /usr/include/php/Zend/zend.h:51,
from /usr/include/php/main/php.h:34,
from libvirt-php.h:44,
from vncfunc.c:10:
In function 'memset',
inlined from 'vnc_send_client_pointer' at vncfunc.c:252:8:
/usr/include/bits/string3.h:85:3: warning: call to
__builtin___memset_chk will always overflow destination buffer [enabled
by default]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -c -o sockets.o sockets.c -I/usr/include/php
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib
-I/usr/include/libxml2 -DHAVE_CONFIG_H
sockets.c: In function 'socket_has_data':
sockets.c:118:10: warning: unused variable 'result' [-Wunused-variable]
sockets.c: In function 'socket_read':
sockets.c:177:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -shared
-lvirt -rdynamic -o libvirt-php.so vncfunc.o sockets.o libvirt-php.o
-ldl -lvirt -lxml2
echo "Extension compiled as libvirt-php.so"
Extension compiled as libvirt-php.so
13 years
[libvirt] [libvirt-glib 1/2] Wrap storage pool info API
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-storage-pool.c | 44 ++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-storage-pool.h | 21 +++++++++++
libvirt-gobject/libvirt-gobject.sym | 2 +
3 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index da8ada5..3c30a3d 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -189,6 +189,21 @@ gvir_storage_pool_handle_free(GVirStoragePoolHandle *src)
G_DEFINE_BOXED_TYPE(GVirStoragePoolHandle, gvir_storage_pool_handle,
gvir_storage_pool_handle_copy, gvir_storage_pool_handle_free)
+static GVirStoragePoolInfo *
+gvir_storage_pool_info_copy(GVirStoragePoolInfo *info)
+{
+ return g_slice_dup(GVirStoragePoolInfo, info);
+}
+
+static void
+gvir_storage_pool_info_free(GVirStoragePoolInfo *info)
+{
+ g_slice_free(GVirStoragePoolInfo, info);
+}
+
+G_DEFINE_BOXED_TYPE(GVirStoragePoolInfo, gvir_storage_pool_info,
+ gvir_storage_pool_info_copy, gvir_storage_pool_info_free)
+
const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool)
{
GVirStoragePoolPrivate *priv = pool->priv;
@@ -237,6 +252,35 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
return conf;
}
+/**
+ * gvir_storage_pool_get_info:
+ * @pool: the storage_pool
+ * Returns: (transfer full): the info
+ */
+GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
+ GError **err)
+{
+ GVirStoragePoolPrivate *priv = pool->priv;
+ virStoragePoolInfo info;
+ GVirStoragePoolInfo *ret;
+
+ if (virStoragePoolGetInfo(priv->handle, &info) < 0) {
+ if (err)
+ *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
+ 0,
+ "Unable to get storage pool info");
+ return NULL;
+ }
+
+ ret = g_slice_new(GVirStoragePoolInfo);
+ ret->state = info.state;
+ ret->capacity = info.capacity;
+ ret->allocation = info.allocation;
+ ret->available = info.available;
+
+ return ret;
+}
+
typedef gint (* CountFunction) (virStoragePoolPtr vpool);
typedef gint (* ListFunction) (virStoragePoolPtr vpool, gchar **lst, gint max);
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index d95bb19..436238b 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -36,6 +36,7 @@ G_BEGIN_DECLS
#define GVIR_IS_STORAGE_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_STORAGE_POOL))
#define GVIR_STORAGE_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_STORAGE_POOL, GVirStoragePoolClass))
+#define GVIR_TYPE_STORAGE_POOL_INFO (gvir_storage_pool_info_get_type())
#define GVIR_TYPE_STORAGE_POOL_HANDLE (gvir_storage_pool_handle_get_type())
typedef struct _GVirStoragePool GVirStoragePool;
@@ -58,8 +59,25 @@ struct _GVirStoragePoolClass
gpointer padding[20];
};
+typedef enum {
+ GVIR_STORAGE_POOL_STATE_INACTIVE = 0, /* Not running */
+ GVIR_STORAGE_POOL_STATE_BUILDING = 1, /* Initializing pool, not available */
+ GVIR_STORAGE_POOL_STATE_RUNNING = 2, /* Running normally */
+ GVIR_STORAGE_POOL_STATE_DEGRADED = 3, /* Running degraded */
+ GVIR_STORAGE_POOL_STATE_INACCESSIBLE = 4, /* Running, but not accessible */
+} GVirStoragePoolState;
+
+typedef struct _GVirStoragePoolInfo GVirStoragePoolInfo;
+struct _GVirStoragePoolInfo
+{
+ GVirStoragePoolState state; /* the state */
+ guint64 capacity; /* Logical size bytes */
+ guint64 allocation; /* Current allocation bytes */
+ guint16 available; /* Remaining free space bytes */
+};
GType gvir_storage_pool_get_type(void);
+GType gvir_storage_pool_info_get_type(void);
GType gvir_storage_pool_handle_get_type(void);
const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool);
@@ -69,6 +87,9 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
guint flags,
GError **err);
+GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
+ GError **err);
+
gboolean gvir_storage_pool_refresh(GVirStoragePool *pool,
GCancellable *cancellable,
GError **err);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 61a3a31..55c515b 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -91,10 +91,12 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_secret_get_config;
gvir_storage_pool_get_type;
+ gvir_storage_pool_info_get_type;
gvir_storage_pool_handle_get_type;
gvir_storage_pool_get_name;
gvir_storage_pool_get_uuid;
gvir_storage_pool_get_config;
+ gvir_storage_pool_get_info;
gvir_storage_pool_refresh;
gvir_storage_pool_refresh_async;
gvir_storage_pool_refresh_finish;
--
1.7.7.3
13 years
[libvirt] [PATCH] virsh: Allow other escape characters for console
by Michal Privoznik
Currently virsh supports only ^] as escape character for console.
However, some users might want to use something else. This patch
creates such ability by specifying '-e' switch on virsh command
line.
---
Okay, this patch is meant as RFC mainly but if it got enough ACKs
I will not hesitate to push it. My biggest concern is the way
of telling virsh customized sequence. I am not big fan of new switch,
however we lack virsh.conf in $conf_dir. Maybe it is the right time
for creating it.
Another approach is to pass the sequence as parameter directly to
'console' command.
What's your opinion?
tools/console.c | 28 +++++++++++++++++++++++-----
tools/console.h | 4 +++-
tools/virsh.c | 20 ++++++++++++++++----
tools/virsh.pod | 5 +++++
4 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/tools/console.c b/tools/console.c
index 0f85bc7..db2e17e 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -43,9 +43,13 @@
# include "memory.h"
# include "virterror_internal.h"
-
-/* ie Ctrl-] as per telnet */
-# define CTRL_CLOSE_BRACKET '\35'
+/*
+ * Convert given character to control character.
+ * Basically, we take lower 5 bits unless given
+ * character is DEL (represented by '?'). Then
+ * we return 127
+ */
+# define CONTROL(c) ((c) == '?' ? ((c) | 0x40) : ((c) & 0x1f))
# define VIR_FROM_THIS VIR_FROM_NONE
@@ -66,6 +70,8 @@ struct virConsole {
struct virConsoleBuffer streamToTerminal;
struct virConsoleBuffer terminalToStream;
+
+ char escapeChar;
};
static int got_signal = 0;
@@ -215,7 +221,7 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
virConsoleShutdown(con);
return;
}
- if (con->terminalToStream.data[con->terminalToStream.offset] == CTRL_CLOSE_BRACKET) {
+ if (con->terminalToStream.data[con->terminalToStream.offset] == con->escapeChar) {
virConsoleShutdown(con);
return;
}
@@ -278,7 +284,18 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
}
-int vshRunConsole(virDomainPtr dom, const char *dev_name)
+static char
+vshGetEscapeChar(const char *s)
+{
+ if (*s == '^')
+ return CONTROL(s[1]);
+
+ return *s;
+}
+
+int vshRunConsole(virDomainPtr dom,
+ const char *dev_name,
+ const char *escape_seq)
{
int ret = -1;
struct termios ttyattr, rawattr;
@@ -326,6 +343,7 @@ int vshRunConsole(virDomainPtr dom, const char *dev_name)
goto cleanup;
}
+ con->escapeChar = vshGetEscapeChar(escape_seq);
con->st = virStreamNew(virDomainGetConnect(dom),
VIR_STREAM_NONBLOCK);
if (!con->st)
diff --git a/tools/console.h b/tools/console.h
index 9b05ff1..8cca08f 100644
--- a/tools/console.h
+++ b/tools/console.h
@@ -25,7 +25,9 @@
# ifndef WIN32
-int vshRunConsole(virDomainPtr dom, const char *dev_name);
+int vshRunConsole(virDomainPtr dom,
+ const char *dev_name,
+ const char *escape_seq);
# endif /* !WIN32 */
diff --git a/tools/virsh.c b/tools/virsh.c
index 89fb4e7..1b84980 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -75,6 +75,9 @@ static char *progname;
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
+/* Default escape char Ctrl-] as per telnet */
+#define CTRL_CLOSE_BRACKET "^]"
+
/**
* The log configuration
*/
@@ -249,6 +252,7 @@ typedef struct __vshControl {
virDomainGetState is not supported */
bool useSnapshotOld; /* cannot use virDomainSnapshotGetParent or
virDomainSnapshotNumChildren */
+ const char *escapeChar; /* Escape character for domain console */
} __vshControl;
typedef struct vshCmdGrp {
@@ -796,8 +800,8 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
}
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
- vshPrintExtra(ctl, "%s", _("Escape character is ^]\n"));
- if (vshRunConsole(dom, name) == 0)
+ vshPrintExtra(ctl, _("Escape character is %s\n"), ctl->escapeChar);
+ if (vshRunConsole(dom, name, ctl->escapeChar) == 0)
ret = true;
cleanup:
@@ -16817,6 +16821,7 @@ vshDeinit(vshControl *ctl)
vshReadlineDeinit(ctl);
vshCloseLogFile(ctl);
VIR_FREE(ctl->name);
+ VIR_FREE(ctl->escapeChar);
if (ctl->conn) {
int ret;
if ((ret = virConnectClose(ctl->conn)) != 0) {
@@ -16848,7 +16853,8 @@ vshUsage(void)
" -t | --timing print timing information\n"
" -l | --log <file> output logging to file\n"
" -v | --version[=short] program version\n"
- " -V | --version=long version and full options\n\n"
+ " -V | --version=long version and full options\n"
+ " -e | --escape <char> set escape sequence for console\n\n"
" commands (non interactive mode):\n\n"), progname, progname);
for (grp = cmdGroups; grp->name; grp++) {
@@ -17009,13 +17015,14 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
{"connect", required_argument, NULL, 'c'},
{"readonly", no_argument, NULL, 'r'},
{"log", required_argument, NULL, 'l'},
+ {"escape", required_argument, NULL, 'e'},
{NULL, 0, NULL, 0}
};
/* Standard (non-command) options. The leading + ensures that no
* argument reordering takes place, so that command options are
* not confused with top-level virsh options. */
- while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:", opt, NULL)) != -1) {
+ while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) != -1) {
switch (arg) {
case 'd':
if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
@@ -17050,6 +17057,9 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
case 'l':
ctl->logfile = vshStrdup(ctl, optarg);
break;
+ case 'e':
+ ctl->escapeChar = vshStrdup(ctl, optarg);
+ break;
default:
vshError(ctl, _("unsupported option '-%c'. See --help."), arg);
exit(EXIT_FAILURE);
@@ -17091,6 +17101,8 @@ main(int argc, char **argv)
ctl->imode = true; /* default is interactive mode */
ctl->log_fd = -1; /* Initialize log file descriptor */
ctl->debug = VSH_DEBUG_DEFAULT;
+ ctl->escapeChar = vshStrdup(ctl, CTRL_CLOSE_BRACKET);
+
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
diff --git a/tools/virsh.pod b/tools/virsh.pod
index db872dd..08b761d 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -92,6 +92,11 @@ option of the B<connect> command.
Output elapsed time information for each command.
+=item B<-e>, B<--escape> I<string>
+
+Set alternative escape sequence for I<console> command. By default,
+telnet's ^] is used.
+
=back
=head1 NOTES
--
1.7.3.4
13 years
[libvirt] [PATCH] bridge_driver: Don't define network if XML contains more IPv4 adreses.
by Peter Krempa
Only one IPv4 DHCP definition is supported. Originaly the code checked
for a multiple definition and returned an error, but the new domain
definition was already added to networks. This patch moves the check
before the newly defined network is added to active networks.
*src/network/bridge_driver.c: networkDefine(): - move multiple IPv4
adresses check before
definition is used.
---
src/network/bridge_driver.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c49c25b..0c1563a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2261,70 +2261,71 @@ static virNetworkPtr networkDefine(virConnectPtr conn, const char *xml) {
if (!(def = virNetworkDefParseString(xml)))
goto cleanup;
if (virNetworkObjIsDuplicate(&driver->networks, def, 0) < 0)
goto cleanup;
/* Only the three L3 network types that are configured by libvirt
* need to have a bridge device name / mac address provided
*/
if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
def->forwardType == VIR_NETWORK_FORWARD_NAT ||
def->forwardType == VIR_NETWORK_FORWARD_ROUTE) {
if (virNetworkSetBridgeName(&driver->networks, def, 1))
goto cleanup;
virNetworkSetBridgeMacAddr(def);
}
- if (!(network = virNetworkAssignDef(&driver->networks,
- def)))
- goto cleanup;
- freeDef = false;
-
- network->persistent = 1;
-
- if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) {
- virNetworkRemoveInactive(&driver->networks, network);
- network = NULL;
- goto cleanup;
- }
-
/* We only support dhcp on one IPv4 address per defined network */
for (ii = 0;
(ipdef = virNetworkDefGetIpByIndex(def, AF_UNSPEC, ii));
ii++) {
if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET)) {
if (ipdef->nranges || ipdef->nhosts) {
if (ipv4def) {
networkReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("Multiple dhcp sections found. dhcp is supported only for a single IPv4 address on each network"));
goto cleanup;
} else {
ipv4def = ipdef;
}
}
}
}
- if (ipv4def) {
+
+ if (!(network = virNetworkAssignDef(&driver->networks,
+ def)))
+ goto cleanup;
+ freeDef = false;
+
+ network->persistent = 1;
+
+ if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) {
+ virNetworkRemoveInactive(&driver->networks, network);
+ network = NULL;
+ goto cleanup;
+ }
+
+ if (ipv4def) {
dctx = dnsmasqContextNew(def->name, DNSMASQ_STATE_DIR);
if (dctx == NULL ||
networkBuildDnsmasqHostsfile(dctx, ipv4def, def->dns) < 0 ||
dnsmasqSave(dctx) < 0)
goto cleanup;
}
VIR_INFO("Defining network '%s'", def->name);
ret = virGetNetwork(conn, def->name, def->uuid);
cleanup:
if (freeDef)
virNetworkDefFree(def);
dnsmasqContextFree(dctx);
if (network)
virNetworkObjUnlock(network);
networkDriverUnlock(driver);
return ret;
}
--
1.7.3.4
13 years