~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/usb-msd.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include "usb.h"
12
12
#include "block.h"
13
13
#include "scsi-disk.h"
 
14
#include "console.h"
14
15
 
15
16
//#define DEBUG_MSD
16
17
 
513
514
    qemu_free(s);
514
515
}
515
516
 
516
 
USBDevice *usb_msd_init(const char *filename)
 
517
USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)
517
518
{
518
519
    MSDState *s;
519
520
    BlockDriverState *bdrv;
 
521
    BlockDriver *drv = NULL;
 
522
    const char *p1;
 
523
    char fmt[32];
 
524
 
 
525
    p1 = strchr(filename, ':');
 
526
    if (p1++) {
 
527
        const char *p2;
 
528
 
 
529
        if (strstart(filename, "format=", &p2)) {
 
530
            int len = MIN(p1 - p2, sizeof(fmt));
 
531
            pstrcpy(fmt, len, p2);
 
532
 
 
533
            drv = bdrv_find_format(fmt);
 
534
            if (!drv) {
 
535
                printf("invalid format %s\n", fmt);
 
536
                return NULL;
 
537
            }
 
538
        } else if (*filename != ':') {
 
539
            printf("unrecognized USB mass-storage option %s\n", filename);
 
540
            return NULL;
 
541
        }
 
542
 
 
543
        filename = p1;
 
544
    }
 
545
 
 
546
    if (!*filename) {
 
547
        printf("block device specification needed\n");
 
548
        return NULL;
 
549
    }
520
550
 
521
551
    s = qemu_mallocz(sizeof(MSDState));
522
 
    if (!s)
523
 
        return NULL;
524
552
 
525
553
    bdrv = bdrv_new("usb");
526
 
    if (bdrv_open(bdrv, filename, 0) < 0)
527
 
        goto fail;
528
 
    if (qemu_key_check(bdrv, filename))
 
554
    if (bdrv_open2(bdrv, filename, 0, drv) < 0)
529
555
        goto fail;
530
556
    s->bs = bdrv;
 
557
    *pbs = bdrv;
531
558
 
532
559
    s->dev.speed = USB_SPEED_FULL;
533
560
    s->dev.handle_packet = usb_generic_handle_packet;