Skip to contentSkip to conversation

Trivial patches for 20 December 2011 to 6 January 2012

GIT PULL New Stefan Hajnoczi 2 participants 11 messages Jan 6, 2012 – Jan 9, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

My pull request from 22 December 2011 was misformatted and therefore not merged. I have included those patches again together with the latest batch of trivial patches.

The following changes since commit c47f3223658119219bbe0b8d09da733d1c06e76f:

Merge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging (2012-01-04 10:06:25 -0600)

are available in the git repository at:

git://github.com/stefanha/qemu.git trivial-patches

Alon Levy (1):
qemu-options.hx: fix tls-channel help text

Markus Armbruster (2):
Strip trailing '\n' from error_report()'s first argument (again) scsi virtio-blk usb-msd: Clean up device init error messages

Peter Maydell (3):
configure: Fix test for supported host CPU type
gdbstub: Fix fd leak in gdbserver_open() error path net/socket.c: Fix fd leak in net_socket_listen_init() error paths

Sebastian Herbszt (1):
Make python mandatory

Stefan Hajnoczi (1):
qemu-nbd: drop loop which can never loop

Stefan Weil (1):
configure: CONFIG_QEMU_INTERP_PREFIX only for user mode

 configure         |   56 +++++++++++++++++++++++-----------------------------
 gdbstub.c         |    2 +
 hw/scsi-disk.c    |    4 +-
 hw/scsi-generic.c |    8 +++---
 hw/usb-bus.c      |   12 +++++-----
 hw/usb-msd.c      |    2 +-
 hw/virtio-blk.c   |    2 +-
 net/socket.c      |    2 +
 qemu-nbd.c        |   10 +++-----
 qemu-options.hx   |    4 +-
 usb-redir.c       |    4 +-
 11 files changed, 51 insertions(+), 55 deletions(-)
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 1/9 qemu-options.hx: fix tls-channel help text

From: Alon Levy <[email protected]>

Remove the default compiled out tunnel channel, add the always available cursor channel. Optimally the man page would depend on compiled in options, but that's harder to do.

RHBZ: 688586

---
 qemu-options.hx |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-options.hx +2 -2
index a60191f..3c3bda8 100644
@@ -857,8 +857,8 @@ The x509 file names can also be configured individually.
 @item tls-ciphers=<list>
 Specify which ciphers to use.
 
-@item tls-channel=[main|display|inputs|record|playback|tunnel]
-@item plaintext-channel=[main|display|inputs|record|playback|tunnel]
+@item tls-channel=[main|display|cursor|inputs|record|playback]
+@item plaintext-channel=[main|display|cursor|inputs|record|playback]
 Force specific channel to be used with or without TLS encryption.  The
 options can be specified multiple times to configure multiple
 channels.  The special name "default" can be used to set the default
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 2/9 Strip trailing '\n' from error_report()'s first argument (again)

In reply to Stefan Hajnoczi

From: Markus Armbruster <[email protected]>

Commit 6daf194d got rid of them, but Hans and Gerd added some more lately. Tracked down with this Coccinelle semantic patch:

@r@

    expression fmt;
    position p;
@@
    error_report(fmt, ...)@p
@script:python@
    fmt << r.fmt;
    p << r.p;
@@
if "\\n" in str(fmt):
    print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt)
---
 hw/usb-bus.c |   12 ++++++------
 usb-redir.c  |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
hw/usb-bus.c +6 -6
index 8203390..bd4afa7 100644
@@ -137,7 +137,7 @@ USBDevice *usb_create(USBBus *bus, const char *name)
         bus = usb_bus_find(-1);
         if (!bus)
             return NULL;
-        error_report("%s: no bus specified, using \"%s\" for \"%s\"\n",
+        error_report("%s: no bus specified, using \"%s\" for \"%s\"",
                 __FUNCTION__, bus->qbus.name, name);
     }
 #endif
@@ -152,12 +152,12 @@ USBDevice *usb_create_simple(USBBus *bus, const char *name)
     int rc;
 
     if (!dev) {
-        error_report("Failed to create USB device '%s'\n", name);
+        error_report("Failed to create USB device '%s'", name);
         return NULL;
     }
     rc = qdev_init(&dev->qdev);
     if (rc < 0) {
-        error_report("Failed to initialize USB device '%s'\n", name);
+        error_report("Failed to initialize USB device '%s'", name);
         return NULL;
     }
     return dev;
@@ -244,7 +244,7 @@ int usb_claim_port(USBDevice *dev)
             }
         }
         if (port == NULL) {
-            error_report("Error: usb port %s (bus %s) not found (in use?)\n",
+            error_report("Error: usb port %s (bus %s) not found (in use?)",
                          dev->port_path, bus->qbus.name);
             return -1;
         }
@@ -255,7 +255,7 @@ int usb_claim_port(USBDevice *dev)
         }
         if (bus->nfree == 0) {
             error_report("Error: tried to attach usb device %s to a bus "
-                         "with no free ports\n", dev->product_desc);
+                         "with no free ports", dev->product_desc);
             return -1;
         }
         port = QTAILQ_FIRST(&bus->free);
@@ -302,7 +302,7 @@ int usb_device_attach(USBDevice *dev)
 
     if (!(port->speedmask & dev->speedmask)) {
         error_report("Warning: speed mismatch trying to attach "
-                     "usb device %s to bus %s\n",
+                     "usb device %s to bus %s",
                      dev->product_desc, bus->qbus.name);
         return -1;
     }
usb-redir.c +2 -2
index a36f2a7..2b53cf3 100644
@@ -174,7 +174,7 @@ static void usbredir_log(void *priv, int level, const char *msg)
         return;
     }
 
-    error_report("%s\n", msg);
+    error_report("%s", msg);
 }
 
 static void usbredir_log_data(USBRedirDevice *dev, const char *desc,
@@ -193,7 +193,7 @@ static void usbredir_log_data(USBRedirDevice *dev, const char *desc,
         for (j = 0; j < 8 && i + j < len; j++) {
             n += sprintf(buf + n, " %02X", data[i + j]);
         }
-        error_report("%s\n", buf);
+        error_report("%s", buf);
     }
 }
 
Signature · 1 line
1.7.7.3
#3 lore raw

PATCH 3/9 scsi virtio-blk usb-msd: Clean up device init error messages

In reply to Stefan Hajnoczi

From: Markus Armbruster <[email protected]>

Replace

    error_report("DEVICE-NAME: MESSAGE");

by just

    error_report("MESSAGE");

in block device init functions.

DEVICE-NAME is bogus in some cases: it's "scsi-disk" for device scsi-hd and scsi-cd, "virtio-blk-pci" for virtio-blk-s390, and "usb-msd" for usb-storage.

There is no real need to put a device name in the message, because error_report() points to the offending command line option already:

$ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -monitor stdio -usb -device virtio-blk-pci
upstream-qemu: -device virtio-blk-pci: virtio-blk-pci: drive property not set
upstream-qemu: -device virtio-blk-pci: Device 'virtio-blk-pci' could not be initialized

And for a monitor command, it's obvious anyway:

$ qemu-system-x86_64 --nodefaults --enable-kvm -vnc :0 -S -monitor stdio -usb
(qemu) device_add virtio-blk-pci
virtio-blk-pci: drive property not set
Device 'virtio-blk-pci' could not be initialized
---
 hw/scsi-disk.c    |    4 ++--
 hw/scsi-generic.c |    8 ++++----
 hw/usb-msd.c      |    2 +-
 hw/virtio-blk.c   |    2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
hw/scsi-disk.c +2 -2
index 505accd..5d8bf53 100644
@@ -1515,7 +1515,7 @@ static int scsi_initfn(SCSIDevice *dev)
     DriveInfo *dinfo;
 
     if (!s->qdev.conf.bs) {
-        error_report("scsi-disk: drive property not set");
+        error_report("drive property not set");
         return -1;
     }
 
@@ -1537,7 +1537,7 @@ static int scsi_initfn(SCSIDevice *dev)
     }
 
     if (bdrv_is_sg(s->qdev.conf.bs)) {
-        error_report("scsi-disk: unwanted /dev/sg*");
+        error_report("unwanted /dev/sg*");
         return -1;
     }
 
hw/scsi-generic.c +4 -4
index 6f7d3db..0aebcdd 100644
@@ -374,13 +374,13 @@ static int scsi_generic_initfn(SCSIDevice *s)
     struct sg_scsi_id scsiid;
 
     if (!s->conf.bs) {
-        error_report("scsi-generic: drive property not set");
+        error_report("drive property not set");
         return -1;
     }
 
     /* check we are really using a /dev/sg* file */
     if (!bdrv_is_sg(s->conf.bs)) {
-        error_report("scsi-generic: not /dev/sg*");
+        error_report("not /dev/sg*");
         return -1;
     }
 
@@ -396,13 +396,13 @@ static int scsi_generic_initfn(SCSIDevice *s)
     /* check we are using a driver managing SG_IO (version 3 and after */
     if (bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
         sg_version < 30000) {
-        error_report("scsi-generic: scsi generic interface too old");
+        error_report("scsi generic interface too old");
         return -1;
     }
 
     /* get LUN of the /dev/sg? */
     if (bdrv_ioctl(s->conf.bs, SG_GET_SCSI_ID, &scsiid)) {
-        error_report("scsi-generic: SG_GET_SCSI_ID ioctl failed");
+        error_report("SG_GET_SCSI_ID ioctl failed");
         return -1;
     }
 
hw/usb-msd.c +1 -1
index 4c06950..b87b929 100644
@@ -517,7 +517,7 @@ static int usb_msd_initfn(USBDevice *dev)
     DriveInfo *dinfo;
 
     if (!bs) {
-        error_report("usb-msd: drive property not set");
+        error_report("drive property not set");
         return -1;
     }
 
hw/virtio-blk.c +1 -1
index ef27421..5e81f53 100644
@@ -569,7 +569,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
     DriveInfo *dinfo;
 
     if (!conf->bs) {
-        error_report("virtio-blk-pci: drive property not set");
+        error_report("drive property not set");
         return NULL;
     }
     if (!bdrv_is_inserted(conf->bs)) {
Signature · 1 line
1.7.7.3
#4 lore raw

PATCH 4/9 configure: CONFIG_QEMU_INTERP_PREFIX only for user mode

In reply to Stefan Hajnoczi

From: Stefan Weil <[email protected]>

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 640e815..af19391 100755
@@ -3395,7 +3395,6 @@ echo "# Automatically generated by configure - do not modify" > $config_target_m
 bflt="no"
 target_nptl="no"
 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
-echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
 gdb_xml_files=""
 target_short_alignment=2
 target_int_alignment=4
@@ -3601,6 +3600,7 @@ if test "$target_softmmu" = "yes" ; then
 fi
 if test "$target_user_only" = "yes" ; then
   echo "CONFIG_USER_ONLY=y" >> $config_target_mak
+  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
 fi
 if test "$target_linux_user" = "yes" ; then
   echo "CONFIG_LINUX_USER=y" >> $config_target_mak
Signature · 1 line
1.7.7.3
#5 lore raw

PATCH 5/9 configure: Fix test for supported host CPU type

In reply to Stefan Hajnoczi

From: Peter Maydell <[email protected]>

The test for whether the host CPU is supported had several problems:
* the attempt to fall back to TCI was done as a duplicate test, very late (so "--cpu foo" would fail early but "--cpu unicore32" would fail late, differently, and after configure had already printed a lot of output)
* a number of CPUs only supported as guests were included in the list of CPUs we would accept as valid hosts, which would result in a late compile failure on those systems rather than a configure failure or fallback to TCI
* bailing out for an unsupported CPU happened before the main option parsing, so "configure --help" wouldn't work

Fix these by folding the setting of ARCH into the first test for supported host CPU, removing spurious guest-only CPU names from it, and moving the "fall back to TCI" code earlier.

---
 configure |   44 +++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 23 deletions(-)
configure +21 -23
index af19391..a1394eb 100755
@@ -300,8 +300,11 @@ else
   cpu=`uname -m`
 fi
 
+ARCH=
+# Normalise host CPU name and set ARCH.
+# Note that this case should only have supported host CPUs, not guests.
 case "$cpu" in
-  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
+  ia64|ppc|ppc64|s390|s390x|sparc64)
     cpu="$cpu"
   ;;
   i386|i486|i586|i686|i86pc|BePC)
@@ -319,20 +322,17 @@ case "$cpu" in
   mips*)
     cpu="mips"
   ;;
-  s390)
-    cpu="s390"
-  ;;
-  s390x)
-    cpu="s390x"
-  ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
   ;;
   *)
-    echo "Unsupported CPU = $cpu"
-    exit 1
+    # This will result in either an error or falling back to TCI later
+    ARCH=unknown
   ;;
 esac
+if test -z "$ARCH"; then
+  ARCH="$cpu"
+fi
 
 # OS specific
 if check_define __linux__ ; then
@@ -1080,6 +1080,18 @@ echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
 fi
 
+# Now we have handled --enable-tcg-interpreter and know we're not just
+# printing the help message, bail out if the host CPU isn't supported.
+if test "$ARCH" = "unknown"; then
+    if test "$tcg_interpreter" = "yes" ; then
+        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
+        ARCH=tci
+    else
+        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
+        exit 1
+    fi
+fi
+
 # check that the C compiler works.
 cat > $TMPC <<EOF
 int main(void) { return 0; }
@@ -2903,20 +2915,6 @@ echo "sysconfdir=$sysconfdir" >> $config_host_mak
 echo "docdir=$docdir" >> $config_host_mak
 echo "confdir=$confdir" >> $config_host_mak
 
-case "$cpu" in
-  i386|x86_64|alpha|arm|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
-    ARCH=$cpu
-  ;;
-  *)
-    if test "$tcg_interpreter" = "yes" ; then
-        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
-        ARCH=tci
-    else
-        echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
-        exit 1
-    fi
-  ;;
-esac
 echo "ARCH=$ARCH" >> $config_host_mak
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
Signature · 1 line
1.7.7.3
#6 lore raw

PATCH 6/9 gdbstub: Fix fd leak in gdbserver_open() error path

In reply to Stefan Hajnoczi

From: Peter Maydell <[email protected]>

Fix a leak of a file descriptor in error exit paths in gdbserver_open().

---
 gdbstub.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
gdbstub.c +2 -0
index a5806ef..7d470b6 100644
@@ -2762,11 +2762,13 @@ static int gdbserver_open(int port)
     ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
     if (ret < 0) {
         perror("bind");
+        close(fd);
         return -1;
     }
     ret = listen(fd, 0);
     if (ret < 0) {
         perror("listen");
+        close(fd);
         return -1;
     }
     return fd;
Signature · 1 line
1.7.7.3
#7 lore raw

PATCH 7/9 net/socket.c: Fix fd leak in net_socket_listen_init() error paths

In reply to Stefan Hajnoczi

From: Peter Maydell <[email protected]>

Fix a leak of a file descriptor due to missing closesocket() calls in error paths in net_socket_listen_init().

---
 net/socket.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/socket.c +2 -0
index aaf9be4..c9d70d3 100644
@@ -427,12 +427,14 @@ static int net_socket_listen_init(VLANState *vlan,
     if (ret < 0) {
         perror("bind");
         g_free(s);
+        closesocket(fd);
         return -1;
     }
     ret = listen(fd, 0);
     if (ret < 0) {
         perror("listen");
         g_free(s);
+        closesocket(fd);
         return -1;
     }
     s->vlan = vlan;
Signature · 1 line
1.7.7.3
#8 lore raw

PATCH 8/9 Make python mandatory

In reply to Stefan Hajnoczi

From: Sebastian Herbszt <[email protected]>

The QEMU build depends on Python so make it an explicit requirement.

---
 configure |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
configure +3 -7
index a1394eb..d88e3ea 100755
@@ -1197,13 +1197,9 @@ if test "$solaris" = "yes" ; then
   fi
 fi
 
-if test "$guest_agent" != "no" ; then
-  if has $python; then
-    :
-  else
-    echo "Python not found. Use --python=/path/to/python"
-    exit 1
-  fi
+if ! has $python; then
+  echo "Python not found. Use --python=/path/to/python"
+  exit 1
 fi
 
 if test -z "$target_list" ; then
Signature · 1 line
1.7.7.3
#9 lore raw

PATCH 9/9 qemu-nbd: drop loop which can never loop

In reply to Stefan Hajnoczi

For some reason nbd_client_thread() has a do..while loop which can never loop, the condition is bogus because we would take a goto instead. Drop the loop.

---
 qemu-nbd.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
qemu-nbd.c +4 -6
index 155b058..eb61c33 100644
@@ -202,12 +202,10 @@ static void *nbd_client_thread(void *arg)
     int ret;
     pthread_t show_parts_thread;
 
-    do {
-        sock = unix_socket_outgoing(sockpath);
-        if (sock == -1) {
-            goto out;
-        }
-    } while (sock == -1);
+    sock = unix_socket_outgoing(sockpath);
+    if (sock == -1) {
+        goto out;
+    }
 
     ret = nbd_receive_negotiate(sock, NULL, &nbdflags,
                                 &size, &blocksize);
Signature · 1 line
1.7.7.3
#10 lore raw
In reply to Stefan Hajnoczi
Quoted 7 lines · Stefan Hajnoczi

My pull request from 22 December 2011 was misformatted and therefore not merged. I have included those patches again together with the latest batch of trivial patches.

The following changes since commit c47f3223658119219bbe0b8d09da733d1c06e76f:

   Merge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging (2012-01-04 10:06:25 -0600)

Pulled a couple days ago and forgot to send a note. Thanks.

Regards,

Anthony Liguori

Quoted 39 lines

are available in the git repository at:

git://github.com/stefanha/qemu.git trivial-patches

Alon Levy (1):
qemu-options.hx: fix tls-channel help text

Markus Armbruster (2):
Strip trailing '\n' from error_report()'s first argument (again) scsi virtio-blk usb-msd: Clean up device init error messages

Peter Maydell (3):
configure: Fix test for supported host CPU type
gdbstub: Fix fd leak in gdbserver_open() error path net/socket.c: Fix fd leak in net_socket_listen_init() error paths

Sebastian Herbszt (1):
Make python mandatory

Stefan Hajnoczi (1):
qemu-nbd: drop loop which can never loop

Stefan Weil (1):
configure: CONFIG_QEMU_INTERP_PREFIX only for user mode

  configure         |   56 +++++++++++++++++++++++-----------------------------
  gdbstub.c         |    2 +
  hw/scsi-disk.c    |    4 +-
  hw/scsi-generic.c |    8 +++---
  hw/usb-bus.c      |   12 +++++-----
  hw/usb-msd.c      |    2 +-
  hw/virtio-blk.c   |    2 +-
  net/socket.c      |    2 +
  qemu-nbd.c        |   10 +++-----
  qemu-options.hx   |    4 +-
  usb-redir.c       |    4 +-
  11 files changed, 51 insertions(+), 55 deletions(-)