On Mon, Apr 01, 2013 at 08:00:53PM +0800, Han Cheng wrote: > The only parameter in -drive affect scsi-generic is readonly. Introduce > <readonly/> to <hostdev>. > The helper function to look up disk controller model may be used by scsi > hostdev. But it should be changed to use info. > > Signed-off-by: Han Cheng <hanc.fnst@xxxxxxxxxxxxxx> > --- > docs/formatdomain.html.in | 3 +++ > docs/schemas/domaincommon.rng | 5 +++++ > src/conf/domain_conf.c | 6 +++--- > src/conf/domain_conf.h | 6 ++++-- > src/libvirt_private.syms | 2 +- > src/qemu/qemu_command.c | 4 ++-- > 6 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in > index cf382e8..a6bacfa 100644 > --- a/docs/formatdomain.html.in > +++ b/docs/formatdomain.html.in > @@ -2257,6 +2257,9 @@ > <code>id</code> attribute that specifies the USB vendor and product id. > The ids can be given in decimal, hexadecimal (starting with 0x) or > octal (starting with 0) form.</dd> > + <dt><code>readonly</code></dt> > + <dd>Specifies that the device is readonly. > + <span class="since">Since 0.13.0</span> for SCSI devices.</dd> 0.13.0 -> 1.0.5 version 1.0.4 is just out. > <dt><code>boot</code></dt> > <dd>Specifies that the device is bootable. The <code>order</code> > attribute determines the order in which devices will be tried during > diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng > index 8d7e6db..ccf0913 100644 > --- a/docs/schemas/domaincommon.rng > +++ b/docs/schemas/domaincommon.rng > @@ -2911,6 +2911,11 @@ > <ref name="alias"/> > </optional> > <optional> > + <element name='readonly'> > + <empty/> > + </element> > + </optional> > + <optional> > <ref name="deviceBoot"/> > </optional> > <optional> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index f3fca7f..d9d6b9f 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -3452,8 +3452,8 @@ error: > } > > int > -virDomainDiskFindControllerModel(virDomainDefPtr def, > - virDomainDiskDefPtr disk, > +virDomainDeviceFindControllerModel(virDomainDefPtr def, > + virDomainDeviceInfoPtr info, > int controllerType) Indentation. > { > int model = -1; > @@ -3461,7 +3461,7 @@ virDomainDiskFindControllerModel(virDomainDefPtr def, > > for (i = 0; i < def->ncontrollers; i++) { > if (def->controllers[i]->type == controllerType && > - def->controllers[i]->idx == disk->info.addr.drive.controller) > + def->controllers[i]->idx == info->addr.drive.controller) > model = def->controllers[i]->model; > } > > diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h > index edddf25..f8e3973 100644 > --- a/src/conf/domain_conf.h > +++ b/src/conf/domain_conf.h > @@ -439,6 +439,8 @@ struct _virDomainHostdevDef { > } source; > virDomainHostdevOrigStates origstates; > virDomainDeviceInfoPtr info; /* Guest address */ > + /* readonly is only used for scsi hostdev */ > + unsigned int readonly; bool readonly; > }; > > /* Two types of disk backends */ > @@ -1981,8 +1983,8 @@ void virDomainInputDefFree(virDomainInputDefPtr def); > void virDomainDiskDefFree(virDomainDiskDefPtr def); > void virDomainLeaseDefFree(virDomainLeaseDefPtr def); > void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def); > -int virDomainDiskFindControllerModel(virDomainDefPtr def, > - virDomainDiskDefPtr disk, > +int virDomainDeviceFindControllerModel(virDomainDefPtr def, > + virDomainDeviceInfoPtr info, > int controllerType); Indentation. > virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def, > int bus, > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index 96eea0a..f2eefc3 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -128,6 +128,7 @@ virDomainDeviceAddressTypeToString; > virDomainDeviceDefCopy; > virDomainDeviceDefFree; > virDomainDeviceDefParse; > +virDomainDeviceFindControllerModel; > virDomainDeviceInfoCopy; > virDomainDeviceInfoIterate; > virDomainDeviceTypeToString; > @@ -145,7 +146,6 @@ virDomainDiskDeviceTypeToString; > virDomainDiskErrorPolicyTypeFromString; > virDomainDiskErrorPolicyTypeToString; > virDomainDiskFindByBusAndDst; > -virDomainDiskFindControllerModel; > virDomainDiskGeometryTransTypeFromString; > virDomainDiskGeometryTransTypeToString; > virDomainDiskHostDefFree; > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index a0c278f..eac72c2 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -557,7 +557,7 @@ qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def, > if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { > if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { > controllerModel = > - virDomainDiskFindControllerModel(def, disk, > + virDomainInfoFindControllerModel(def, &disk->info, s/virDomainInfoFindControllerModel/virDomainDeviceFindControllerModel/ It's a good habit to always test your patches before sending them out. > VIR_DOMAIN_CONTROLLER_TYPE_SCSI); > > if ((qemuSetScsiControllerModel(def, qemuCaps, &controllerModel)) < 0) > @@ -3179,7 +3179,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def, > } > > controllerModel = > - virDomainDiskFindControllerModel(def, disk, > + virDomainInfoFindControllerModel(def, &disk->info, s/virDomainInfoFindControllerModel/virDomainDeviceFindControllerModel/ > VIR_DOMAIN_CONTROLLER_TYPE_SCSI); > if ((qemuSetScsiControllerModel(def, qemuCaps, &controllerModel)) < 0) > goto error; > -- > 1.7.1 > > -- > libvir-list mailing list > libvir-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list