git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pwrite: Check offset is not negative.
[libguestfs.git]
/
src
/
launch.c
diff --git
a/src/launch.c
b/src/launch.c
index
1e1ea8e
..
f9d8329
100644
(file)
--- a/
src/launch.c
+++ b/
src/launch.c
@@
-61,9
+61,7
@@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in.h>
-#include "c-ctype.h"
#include "glthread/lock.h"
#include "glthread/lock.h"
-#include "ignore-value.h"
#include "guestfs.h"
#include "guestfs-internal.h"
#include "guestfs.h"
#include "guestfs-internal.h"
@@
-251,10
+249,7
@@
guestfs__launch (guestfs_h *g)
/* Make the temporary directory. */
if (!g->tmpdir) {
/* Make the temporary directory. */
if (!g->tmpdir) {
- const char *tmpdir = guestfs___tmpdir ();
- char dir_template[strlen (tmpdir) + 32];
- sprintf (dir_template, "%s/libguestfsXXXXXX", tmpdir);
-
+ TMP_TEMPLATE_ON_STACK (dir_template);
g->tmpdir = safe_strdup (g, dir_template);
if (mkdtemp (g->tmpdir) == NULL) {
perrorf (g, _("%s: cannot create temporary directory"), dir_template);
g->tmpdir = safe_strdup (g, dir_template);
if (mkdtemp (g->tmpdir) == NULL) {
perrorf (g, _("%s: cannot create temporary directory"), dir_template);
@@
-342,6
+337,9
@@
guestfs__launch (guestfs_h *g)
*/
g->cmdline[0] = g->qemu;
*/
g->cmdline[0] = g->qemu;
+ if (qemu_supports (g, "-nodefconfig"))
+ add_cmdline (g, "-nodefconfig");
+
/* qemu sometimes needs this option to enable hardware
* virtualization, but some versions of 'qemu-kvm' will use KVM
* regardless (even where this option appears in the help text).
/* qemu sometimes needs this option to enable hardware
* virtualization, but some versions of 'qemu-kvm' will use KVM
* regardless (even where this option appears in the help text).
@@
-410,6
+408,14
@@
guestfs__launch (guestfs_h *g)
add_cmdline (g, "-device");
add_cmdline (g, "virtserialport,chardev=channel0,name=org.libguestfs.channel.0");
add_cmdline (g, "-device");
add_cmdline (g, "virtserialport,chardev=channel0,name=org.libguestfs.channel.0");
+ /* Enable user networking. */
+ if (g->enable_network) {
+ add_cmdline (g, "-netdev");
+ add_cmdline (g, "user,id=usernet");
+ add_cmdline (g, "-device");
+ add_cmdline (g, NET_IF ",netdev=usernet");
+ }
+
#define LINUX_CMDLINE \
"panic=1 " /* force kernel to panic if daemon exits */ \
"console=ttyS0 " /* serial console */ \
#define LINUX_CMDLINE \
"panic=1 " /* force kernel to panic if daemon exits */ \
"console=ttyS0 " /* serial console */ \
@@
-502,6
+508,8
@@
guestfs__launch (guestfs_h *g)
kernel = NULL;
free (initrd);
initrd = NULL;
kernel = NULL;
free (initrd);
initrd = NULL;
+ free (appliance);
+ appliance = NULL;
/* Fork the recovery process off which will kill qemu if the parent
* process fails to do so (eg. if the parent segfaults).
/* Fork the recovery process off which will kill qemu if the parent
* process fails to do so (eg. if the parent segfaults).
@@
-638,8
+646,11
@@
guestfs__launch (guestfs_h *g)
return -1;
}
return -1;
}
+/* Return the location of the tmpdir (eg. "/tmp") and allow users
+ * to override it at runtime using $TMPDIR.
+ */
const char *
const char *
-guestfs_
__
tmpdir (void)
+guestfs_tmpdir (void)
{
const char *tmpdir;
{
const char *tmpdir;
@@
-753,7
+764,7
@@
test_qemu (guestfs_h *g)
goto error;
snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -nographic -version 2>/dev/null",
goto error;
snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -nographic -version 2>/dev/null",
- g->qemu);
+
g->qemu);
fp = popen (cmd, "r");
if (fp) {
fp = popen (cmd, "r");
if (fp) {