[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] net: provide a friendly message when a user passes
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH] net: provide a friendly message when a user passes a bad -net tap, fd=X |
Date: |
Fri, 8 Oct 2010 17:04:56 -0500 |
A lot of people copy libvirt's command line from ps -ef and then wonder why the
VM isn't working correctly. Let's be kind and tell them what they should do
instead.
Without this patch, if you run with an invalid -net tap,fd=X, the guest still
runs and we poll 100% on a bad file descriptor. With this patch, you get:
qemu: -net tap,fd=42: invalid fd= for tap network device. If you're copying
from libvirt, use `virsh dom2xml-to-native' instead
qemu: -net tap,fd=42: Device 'tap' could not be initialized
Signed-off-by: Anthony Liguori <address@hidden>
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 1d83400..5f9f749 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -64,7 +64,7 @@
#define UHCI_PORT_CSC (1 << 1)
#define UHCI_PORT_CCS (1 << 0)
-#define FRAME_TIMER_FREQ 1000
+#define FRAME_TIMER_FREQ 500
#define FRAME_MAX_LOOPS 100
@@ -1054,7 +1054,7 @@ static void uhci_frame_timer(void *opaque)
UHCIState *s = opaque;
/* prepare the timer for the next frame */
- s->expire_time += (get_ticks_per_sec() / FRAME_TIMER_FREQ);
+ s->expire_time = qemu_get_clock(vm_clock) + (get_ticks_per_sec() /
FRAME_TIMER_FREQ);
if (!(s->cmd & UHCI_CMD_RS)) {
/* Full stop */
diff --git a/net/tap.c b/net/tap.c
index 0147dab..45b1fb6 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -405,6 +405,8 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
int fd, vnet_hdr = 0;
if (qemu_opt_get(opts, "fd")) {
+ int flags;
+
if (qemu_opt_get(opts, "ifname") ||
qemu_opt_get(opts, "script") ||
qemu_opt_get(opts, "downscript") ||
@@ -418,6 +420,11 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
return -1;
}
+ if (fcntl(fd, F_GETFL, &flags) == -1) {
+ error_report("invalid fd= for tap network device. If you're
copying from libvirt, use `virsh dom2xml-to-native' instead");
+ return -1;
+ }
+
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
--
1.7.0.4
- [Qemu-devel] [PATCH] net: provide a friendly message when a user passes a bad -net tap, fd=X,
Anthony Liguori <=