[libvirt] unchecked malloc+syscall uses
by Jim Meyering
I was looking through recent changes and spotted two potential
NULL-dereferences in this change set:
http://git.et.redhat.com/?p=libvirt.git;a=commitdiff;h=70c01b4c1adea75e9
In src/opennebula/one_client.c:
+ one_client.url=(char *)malloc(64);
+ snprintf(one_client.url, 63, "http://localhost:%d/RPC2", ONED_PORT);
+#else
+ one_client.url=(char *)"http://localhost:2633/RPC2";
+#endif
--
+ file_text=(char *)malloc(size+1);
+ bytes_read=read(file, file_text, size);
+ close(file);
+
+ if(bytes_read==size) {
Perhaps of more immediate concern,
these syscalls are not checked for failure:
+ file=open(template_file, O_RDONLY);
+ size=lseek(file, 0, SEEK_END);
+ lseek(file, 0, SEEK_SET);
and same for the "read" syscall above.
Note, this is just the result of a few minutes cursory review.
15 years, 5 months
[libvirt] More then one pci device possible with libvirt and pci passthrough?
by Mirko Raasch
Hi,
i want to use more then one pci card in my debian guest.
But when i start the guest, the log says:
libvirtd: 15:44:55.459: warning : pciTrySecondaryBusReset:483 : Other
devices on bus with 0000:05:01.0, not doing bus reset
With "/usr/bin/qemu-system-x86_64 -m 512 -name test -hda
/media/vm/test.img -boot c -vnc :2 -k de -pcidevice host=05:01.0
-pcidevice host=05:02.0 -pcidevice host=05:03.0" there seems to be no
problems.
How can i start my guest with three pci devices passed through and libvirt?
My hostdev section in the xml looks like this:
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x05' slot='0x01' function='0x0'/>
</source>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x05' slot='0x02' function='0x0'/>
</source>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x05' slot='0x03' function='0x0'/>
</source>
</hostdev>
Greetings
Mirko
15 years, 5 months
[libvirt] Can't scale XP on remote
by sean darcy
Just starting out with an XP guest on Fedora 11 kvm. I'm using
virt-manager to connect from a laptop.
Server:
kernel-2.6.29.4-167.fc11.x86_64
qemu-*-0.10.50-6.kvm86.fc11.x86_64
libvirt-0.6.4-2.fc11.x86_64
On the laptop:
virt-manager-0.7.0-5.fc11.i586
libvirt-0.6.2-11.fc11.i586
The console comes, and XP runs fine. But, screen is scaled too large
vertically for my laptop screen which is 1280x800. Only with fullscreen
can I see the bottom menu bar. I would have assumed I could change the
size of the screen (even if not the aspect ratio), but I can't.
Am I doing something wrong, or is this just The Way Things Are?
sean
15 years, 5 months
[libvirt] [PATCH 3/5] disk geometry
by Henrik Persson
Reads the disk geometry to be able to align disk partitions on cylinder boundries.
Msdos partition tables really like this stuff.
15 years, 5 months
[libvirt] [PATCH] Don't disable all logging with --disable-debug
by Amy Griffis
This patch changes the automake conditional for debugging to
disable only the debug output, not the entire logging module.
Since the logging symbols are always visible now, I moved them to
libvirt_private.syms and got rid of libvirt_debug.syms. I noticed
that debugFlag wasn't being used anymore, so I removed that too.
There was some code in __virExec where if you called with NULLs
for childout and childerr, it would conditionally set the fds to
either -1 or the /dev/null fd depending on ENABLE_DEBUG. I'm not
sure why the difference, but it seemed safe to remove the entire
conditional section since either setting is effectively treated
the same way in the following code.
Signed-off-by: Amy Griffis <amy.griffis(a)hp.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index f65e7ad..23a1843 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -498,10 +498,6 @@ EXTRA_DIST += \
# symbols aren't present at all.
#
-if ENABLE_DEBUG
-USED_SYM_FILES += libvirt_debug.syms
-endif
-
if WITH_DRIVER_MODULES
USED_SYM_FILES += libvirt_driver_modules.syms
endif
@@ -517,7 +513,6 @@ endif
EXTRA_DIST += \
libvirt_public.syms \
libvirt_private.syms \
- libvirt_debug.syms \
libvirt_driver_modules.syms \
libvirt_bridge.syms \
libvirt_linux.syms
diff --git a/src/libvirt.c b/src/libvirt.c
index bf49018..bcb707e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -256,9 +256,7 @@ winsock_init (void)
int
virInitialize(void)
{
-#ifdef ENABLE_DEBUG
char *debugEnv;
-#endif
if (initialized)
return(0);
@@ -269,7 +267,6 @@ virInitialize(void)
virRandomInitialize(time(NULL) ^ getpid()))
return -1;
-#ifdef ENABLE_DEBUG
debugEnv = getenv("LIBVIRT_DEBUG");
if (debugEnv && *debugEnv && *debugEnv != '0') {
if (STREQ(debugEnv, "2") || STREQ(debugEnv, "info"))
@@ -287,7 +284,6 @@ virInitialize(void)
debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
if (debugEnv)
virLogParseOutputs(debugEnv);
-#endif
DEBUG0("register drivers");
@@ -1055,13 +1051,11 @@ do_open (const char *name,
/* Secondary driver for storage. Optional */
for (i = 0; i < virStorageDriverTabCount; i++) {
res = virStorageDriverTab[i]->open (ret, auth, flags);
-#ifdef ENABLE_DEBUG
DEBUG("storage driver %d %s returned %s",
i, virStorageDriverTab[i]->name,
res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" :
(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
-#endif
if (res == VIR_DRV_OPEN_ERROR) {
if (0 && STREQ(virStorageDriverTab[i]->name, "remote")) {
virLibConnWarning (NULL, VIR_WAR_NO_STORAGE,
diff --git a/src/libvirt_debug.syms b/src/libvirt_debug.syms
deleted file mode 100644
index 1742a0b..0000000
--- a/src/libvirt_debug.syms
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# These symbols are dependent upon --enable-debug.
-#
-
-
-# libvirt_internal.h
-debugFlag;
-
-
-# logging.h
-virLogMessage;
-virLogSetDefaultPriority;
-virLogDefineFilter;
-virLogDefineOutput;
-virLogParseFilters;
-virLogParseOutputs;
-virLogStartup;
-virLogShutdown;
-virLogReset;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 309d7f9..3958d9b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -192,6 +192,18 @@ virRegisterStorageDriver;
virRegisterDeviceMonitor;
+# logging.h
+virLogMessage;
+virLogSetDefaultPriority;
+virLogDefineFilter;
+virLogDefineOutput;
+virLogParseFilters;
+virLogParseOutputs;
+virLogStartup;
+virLogShutdown;
+virLogReset;
+
+
# memory.h
virAlloc;
virAllocN;
diff --git a/src/logging.c b/src/logging.c
index 83e07cc..fd1d5d4 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -39,9 +39,6 @@
#include "util.h"
#include "threads.h"
-#ifdef ENABLE_DEBUG
-int debugFlag = 0;
-
/*
* Macro used to format the message as a string in virLogMessage
* and borrowed from libxml2 (also used in virRaiseError)
@@ -793,5 +790,4 @@ int virLogParseFilters(const char *filters) {
}
return(ret);
}
-#endif /* ENABLE_DEBUG */
diff --git a/src/logging.h b/src/logging.h
index 7ea8935..d99bb31 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -32,22 +32,17 @@
#ifdef ENABLE_DEBUG
#define VIR_DEBUG_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, fmt, __VA_ARGS__)
+#else
+#define VIR_DEBUG_INT(category, f, l, fmt,...) \
+ do { } while (0)
+#endif /* !ENABLE_DEBUG */
+
#define VIR_INFO_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_INFO, f, l, 0, fmt, __VA_ARGS__)
#define VIR_WARN_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_WARN, f, l, 0, fmt, __VA_ARGS__)
#define VIR_ERROR_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_ERROR, f, l, 0, fmt, __VA_ARGS__)
-#else
-#define VIR_DEBUG_INT(category, f, l, fmt,...) \
- do { } while (0)
-#define VIR_INFO_INT(category, f, l, fmt,...) \
- do { } while (0)
-#define VIR_WARN_INT(category, f, l, fmt,...) \
- do { } while (0)
-#define VIR_ERROR_INT(category, f, l, fmt,...) \
- do { } while (0)
-#endif /* !ENABLE_DEBUG */
#define VIR_DEBUG(fmt,...) \
VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
@@ -108,8 +103,6 @@ typedef int (*virLogOutputFunc) (const char *category, int priority,
*/
typedef void (*virLogCloseFunc) (void *data);
-#ifdef ENABLE_DEBUG
-
extern int virLogSetDefaultPriority(int priority);
extern int virLogDefineFilter(const char *match, int priority, int flags);
extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c,
@@ -128,18 +121,4 @@ extern void virLogMessage(const char *category, int priority,
const char *funcname, long long linenr, int flags,
const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 6, 7);
-#else /* ENABLE_DEBUG */
-
-#define virLogSetDefaultPriority(p)
-#define virLogDefineFilter(m, p, f)
-#define virLogDefineOutput(func, c, d, p, f)
-#define virLogStartup()
-#define virLogReset()
-#define virLogShutdown()
-#define virLogParseFilters(f)
-#define virLogParseOutputs(o)
-#define virLogMessage(c, p, func, l, f, fmt, __VA_ARGS__)
-
-#endif /* ENABLE_DEBUG */
-
#endif
diff --git a/src/util.c b/src/util.c
index 8b746f5..408e17a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -349,10 +349,6 @@ __virExec(virConnectPtr conn,
} else {
childout = *outfd;
}
-#ifndef ENABLE_DEBUG
- } else {
- childout = null;
-#endif
}
if (errfd != NULL) {
@@ -380,10 +376,6 @@ __virExec(virConnectPtr conn,
} else {
childerr = *errfd;
}
-#ifndef ENABLE_DEBUG
- } else {
- childerr = null;
-#endif
}
if ((pid = fork()) < 0) {
15 years, 5 months