Skip to contentSkip to conversation

Block patches

GIT PULL New Kevin Wolf 2 participants 8 messages May 3, 2011 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

The following changes since commit 57aa265d462a64a06268be26d49020729cff56c1:

lm32: add Milkymist Minimac2 support (2011-05-03 10:48:40 +0200)

are available in the git repository at:
git://repo.or.cz/qemu/kevin.git for-anthony

Alon Levy (1):
ide/atapi: fix set but unused

Amit Shah (2):
atapi: Move comment to proper place
atapi: Explain why we need a 'media not present' state

Jes Sorensen (1):
qemu-progress.c: printf isn't signal safe

Kevin Wolf (1):
qemu-img resize: Fix option parsing

Nick Thomas (1):
NBD: Avoid leaking a couple of strings when the NBD device is closed

 block/nbd.c     |    4 ++++
 hw/ide/atapi.c  |   14 +++++++++-----
 qemu-img.c      |   13 +++++++++++--
 qemu-progress.c |    7 ++++++-
 4 files changed, 30 insertions(+), 8 deletions(-)
author
#1 lore raw

PATCH 1/6 qemu-img resize: Fix option parsing

For shrinking images, you're supposed to use a negative size. However, the leading minus makes getopt think that it's an option and so you get the help text if you don't use -- like in 'qemu-img resize test.img -- -1G'.

This patch handles the size first and removes it from the argument list so that getopt won't even try to interpret it and you don't need -- any more.

---
 qemu-img.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
qemu-img.c +11 -2
index ed5ba91..e825123 100644
@@ -1442,6 +1442,16 @@ static int img_resize(int argc, char **argv)
         { NULL }
     };
 
+    /* Remove size from argv manually so that negative numbers are not treated
+     * as options by getopt. */
+    if (argc < 3) {
+        help();
+        return 1;
+    }
+
+    size = argv[--argc];
+
+    /* Parse getopt arguments */
     fmt = NULL;
     for(;;) {
         c = getopt(argc, argv, "f:h");
@@ -1458,11 +1468,10 @@ static int img_resize(int argc, char **argv)
             break;
         }
     }
-    if (optind + 1 >= argc) {
+    if (optind >= argc) {
         help();
     }
     filename = argv[optind++];
-    size = argv[optind++];
 
     /* Choose grow, shrink, or absolute resize mode */
     switch (size[0]) {
Signature · 1 line
1.7.2.3
author
#2 lore raw

PATCH 2/6 atapi: Move comment to proper place

In reply to Kevin Wolf

From: Amit Shah <[email protected]>

Move misplaced comment for media_is_dvd()

---
 hw/ide/atapi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ide/atapi.c +1 -1
index 690a0ab..86b18d8 100644
@@ -71,12 +71,12 @@ static void lba_to_msf(uint8_t *buf, int lba)
     buf[2] = lba % 75;
 }
 
-/* XXX: DVDs that could fit on a CD will be reported as a CD */
 static inline int media_present(IDEState *s)
 {
     return (s->nb_sectors > 0);
 }
 
+/* XXX: DVDs that could fit on a CD will be reported as a CD */
 static inline int media_is_dvd(IDEState *s)
 {
     return (media_present(s) && s->nb_sectors > CD_MAX_SECTORS);
Signature · 1 line
1.7.2.3
author
#3 lore raw

PATCH 3/6 atapi: Explain why we need a 'media not present' state

In reply to Kevin Wolf

From: Amit Shah <[email protected]>

After the re-org of the atapi code, it might not be intuitive for a reader of the code to understand why we're inserting a 'media not present' state between cd changes.

---
 hw/ide/atapi.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
hw/ide/atapi.c +7 -1
index 86b18d8..58febc0 100644
@@ -1106,7 +1106,13 @@ void ide_atapi_cmd(IDEState *s)
         ide_atapi_cmd_check_status(s);
         return;
     }
-
+    /*
+     * When a CD gets changed, we have to report an ejected state and
+     * then a loaded state to guests so that they detect tray
+     * open/close and media change events.  Guests that do not use
+     * GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close
+     * states rely on this behavior.
+     */
     if (bdrv_is_inserted(s->bs) && s->cdrom_changed) {
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
 
Signature · 1 line
1.7.2.3
author
#4 lore raw

PATCH 4/6 ide/atapi: fix set but unused

In reply to Kevin Wolf

From: Alon Levy <[email protected]>

---
 hw/ide/atapi.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
hw/ide/atapi.c +1 -3
index 58febc0..fe2fb0b 100644
@@ -1080,17 +1080,15 @@ static const struct {
 
 void ide_atapi_cmd(IDEState *s)
 {
-    const uint8_t *packet;
     uint8_t *buf;
 
-    packet = s->io_buffer;
     buf = s->io_buffer;
 #ifdef DEBUG_IDE_ATAPI
     {
         int i;
         printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl << 8));
         for(i = 0; i < ATAPI_PACKET_SIZE; i++) {
-            printf(" %02x", packet[i]);
+            printf(" %02x", buf[i]);
         }
         printf("\n");
     }
Signature · 1 line
1.7.2.3
author
#5 lore raw

PATCH 5/6 qemu-progress.c: printf isn't signal safe

In reply to Kevin Wolf

From: Jes Sorensen <[email protected]>

Change the signal handling to indicate a signal is pending, rather then printing directly from the signal handler.

In addition make the signal prints go to stderr, rather than stdout.

---
 qemu-progress.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
qemu-progress.c +6 -1
index e1feb89..a4894c0 100644
@@ -37,6 +37,7 @@ struct progress_state {
 };
 
 static struct progress_state state;
+static volatile sig_atomic_t print_pending;
 
 /*
  * Simple progress print function.
@@ -63,12 +64,16 @@ static void progress_simple_init(void)
 #ifdef CONFIG_POSIX
 static void sigusr_print(int signal)
 {
-    printf("    (%3.2f/100%%)\n", state.current);
+    print_pending = 1;
 }
 #endif
 
 static void progress_dummy_print(void)
 {
+    if (print_pending) {
+        fprintf(stderr, "    (%3.2f/100%%)\n", state.current);
+        print_pending = 0;
+    }
 }
 
 static void progress_dummy_end(void)
Signature · 1 line
1.7.2.3
author
#6 lore raw

PATCH 6/6 NBD: Avoid leaking a couple of strings when the NBD device is closed

In reply to Kevin Wolf

From: Nick Thomas <[email protected]>

---
 block/nbd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
block/nbd.c +4 -0
index 1d6b225..7a52f62 100644
@@ -239,6 +239,10 @@ static int nbd_write(BlockDriverState *bs, int64_t sector_num,
 
 static void nbd_close(BlockDriverState *bs)
 {
+    BDRVNBDState *s = bs->opaque;
+    qemu_free(s->export_name);
+    qemu_free(s->host_spec);
+
     nbd_teardown_connection(bs);
 }
 
Signature · 1 line
1.7.2.3
#7 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

The following changes since commit 57aa265d462a64a06268be26d49020729cff56c1:

   lm32: add Milkymist Minimac2 support (2011-05-03 10:48:40 +0200)

are available in the git repository at:
git://repo.or.cz/qemu/kevin.git for-anthony

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines

Alon Levy (1):
ide/atapi: fix set but unused

Amit Shah (2):
atapi: Move comment to proper place
atapi: Explain why we need a 'media not present' state

Jes Sorensen (1):
qemu-progress.c: printf isn't signal safe

Kevin Wolf (1):
qemu-img resize: Fix option parsing

Nick Thomas (1):
NBD: Avoid leaking a couple of strings when the NBD device is closed

  block/nbd.c     |    4 ++++
  hw/ide/atapi.c  |   14 +++++++++-----
  qemu-img.c      |   13 +++++++++++--
  qemu-progress.c |    7 ++++++-
  4 files changed, 30 insertions(+), 8 deletions(-)