1. 04 Feb, 2011 13 commits
  2. 02 Feb, 2011 1 commit
  3. 01 Feb, 2011 22 commits
  4. 31 Jan, 2011 4 commits
    • Anthony Liguori's avatar
      2685d296
    • Markus Armbruster's avatar
      blockdev: Fix drive_add for drives without media · 319ae529
      Markus Armbruster authored
      
      
      Watch this:
      
          (qemu) drive_add 0 if=none
          (qemu) info block
          none0: type=hd removable=0 [not inserted]
          (qemu) drive_del none0
          Segmentation fault (core dumped)
      
      add_init_drive() is confused about drive_init()'s failure modes, and
      cleans up when it shouldn't.  This leaves the DriveInfo with member
      opts dangling.  drive_del attempts to free it, and dies.
      
      drive_init() behaves as follows:
      
      * If it created a drive with media, it returns its DriveInfo.
      
      * If it created a drive without media, it clears *fatal_error and
        returns NULL.
      
      * If it couldn't create a drive, it sets *fatal_error and returns
        NULL.
      
      Of its three callers:
      
      * drive_init_func() is correct.
      
      * usb_msd_init() assumes drive_init() failed when it returns NULL.
        This is correct only because it always passes option "file", and
        "drive without media" can't happen then.
      
      * add_init_drive() assumes drive_init() failed when it returns NULL.
        This is incorrect.
      
      Clean up drive_init() to return NULL on failure and only on failure.
      Drop its parameter fatal_error.
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      319ae529
    • Markus Armbruster's avatar
      blockdev: Replace drive_add()'s fmt, ... by optstr parameter · 5645b0f4
      Markus Armbruster authored
      
      
      Let the callers build the optstr.  Only one wants to.  All the others
      become simpler, because they don't have to worry about escaping '%'.
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      5645b0f4
    • Markus Armbruster's avatar
      blockdev: Reject multiple definitions for the same drive · 4e5d9b57
      Markus Armbruster authored
      
      
      We silently ignore multiple definitions for the same drive:
      
          $ qemu-system-x86_64 -nodefaults -vnc :1 -S -monitor stdio -drive if=ide,index=1,file=tmp.qcow2 -drive if=ide,index=1,file=nonexistant
          QEMU 0.13.50 monitor - type 'help' for more information
          (qemu) info block
          ide0-hd1: type=hd removable=0 file=tmp.qcow2 backing_file=tmp.img ro=0 drv=qcow2 encrypted=0
      
      With if=none, this can become quite confusing:
      
          $ qemu-system-x86_64 -nodefaults -vnc :1 -S -monitor stdio -drive if=none,index=1,file=tmp.qcow2,id=eins -drive if=none,index=1,file=nonexistant,id=zwei -device ide-drive,drive=eins -device ide-drive,drive=zwei
          qemu-system-x86_64: -device ide-drive,drive=zwei: Property 'ide-drive.drive' can't find value 'zwei'
      
      The second -device fails, because it refers to drive zwei, which got
      silently ignored.
      
      Make multiple drive definitions fail cleanly.
      
      Unfortunately, there's code that relies on multiple drive definitions
      being silently ignored: main() merrily adds default drives even when
      the user already defined these drives.  Fix that up.
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      4e5d9b57