Revision 3e1c0c9a hw/scsi-disk.c

b/hw/scsi-disk.c
398 398
                    "buffer size %zd\n", req->cmd.xfer);
399 399
            pages = buflen++;
400 400
            outbuf[buflen++] = 0x00; // list of supported pages (this page)
401
            outbuf[buflen++] = 0x80; // unit serial number
401
            if (s->serial)
402
                outbuf[buflen++] = 0x80; // unit serial number
402 403
            outbuf[buflen++] = 0x83; // device identification
403 404
            if (s->drive_kind == SCSI_HD) {
404 405
                outbuf[buflen++] = 0xb0; // block limits
......
409 410
        }
410 411
        case 0x80: /* Device serial number, optional */
411 412
        {
412
            int l = strlen(s->serial);
413
            int l;
413 414

  
415
            if (!s->serial) {
416
                DPRINTF("Inquiry (EVPD[Serial number] not supported\n");
417
                return -1;
418
            }
419

  
420
            l = strlen(s->serial);
414 421
            if (l > req->cmd.xfer)
415 422
                l = req->cmd.xfer;
416 423
            if (l > 20)
......
1203 1210
    if (!s->serial) {
1204 1211
        /* try to fall back to value set with legacy -drive serial=... */
1205 1212
        dinfo = drive_get_by_blockdev(s->bs);
1206
        s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : "0");
1213
        if (*dinfo->serial) {
1214
            s->serial = qemu_strdup(dinfo->serial);
1215
        }
1207 1216
    }
1208 1217

  
1209 1218
    if (!s->version) {

Also available in: Unified diff