Adam,
Are you using a seabios which supports booting from ahci? It needs to be
somewhat recent, not more than around 6 weeks old, as there have been
bug fixes in that area.
Bruce
Hi Jim. I
was testing this and found that I could not boot from the sata disks
I defined. When I switch them back to ide, they can be booted just fine.
Perhaps something is missing from the boot order logic?
On Wed, Sep 28, 2011 at 04:43:25PM -0600, Jim Fehlig wrote:
Tested with multiple AHCI controllers and multiple disks attached
to a controller. E.g.,
---
docs/formatdomain.html.in | 9 +++--
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 14 +++++++++
src/qemu/qemu_capabilities.c | 3 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 30 ++++++++++++++++----
.../qemuxml2argv-disk-sata-device.args | 6 ++++
.../qemuxml2argv-disk-sata-device.xml | 25 ++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
9 files changed, 82 insertions(+), 10 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3087d01..b6a0c66 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -972,11 +972,12 @@
as a device ordering hint. The optional bus
attribute specifies the type of disk device to emulate;
possible values are driver specific, with typical values being
- "ide", "scsi", "virtio", "xen" or
"usb". If omitted, the bus type is
- inferred from the style of the device name. eg, a device named 'sda'
- will typically be exported using a SCSI bus.
+ "ide", "scsi", "virtio", "xen",
"usb" or "sata". If omitted, the bus
+ type is inferred from the style of the device name. eg, a device named
+ 'sda' will typically be exported using a SCSI bus.
Since 0.0.3; bus attribute since 0.4.3;
- "usb" attribute value since after 0.4.4
+ "usb" attribute value since after 0.4.4; "sata" attribute
value since
+ 0.9.7
driver
The optional driver element allows specifying further details
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index be98be0..675d55d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -790,6 +790,7 @@
xen
usb
uml
+ sata
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a918679..6a7f296 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2157,6 +2157,15 @@ virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr
def)
def->info.addr.drive.unit = (idx % 2);
break;
+ case VIR_DOMAIN_DISK_BUS_SATA:
+ /* For SATA we define the default mapping to be 6 units
+ * per bus, 1 bus per controller, many controllers */
+ def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
+ def->info.addr.drive.controller = idx / 6;
+ def->info.addr.drive.bus = 0;
+ def->info.addr.drive.unit = idx % 6;
+ break;
+
case VIR_DOMAIN_DISK_BUS_FDC:
/* For FDC we define the default mapping to be 2 units
* per bus, 1 bus per controller, many controllers */
@@ -8675,6 +8684,11 @@ int virDomainDefAddImplicitControllers(virDomainDefPtr def)
VIR_DOMAIN_DISK_BUS_IDE) < 0)
return -1;
+ if (virDomainDefAddDiskControllersForType(def,
+ VIR_DOMAIN_CONTROLLER_TYPE_SATA,
+ VIR_DOMAIN_DISK_BUS_SATA) < 0)
+ return -1;
+
if (virDomainDefMaybeAddVirtioSerialController(def) < 0)
return -1;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 8e20e3f..7122756 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -139,6 +139,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"no-shutdown",
"cache-unsafe", /* 75 */
+ "ich9-ahci",
);
struct qemu_feature_flags {
@@ -1241,6 +1242,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_USB_REDIR);
if (strstr(str, "name \"usb-hub\""))
qemuCapsSet(flags, QEMU_CAPS_USB_HUB);
+ if (strstr(str, "name \"ich9-ahci\""))
+ qemuCapsSet(flags, QEMU_CAPS_ICH9_AHCI);
/* Prefer -chardev spicevmc (detected earlier) over -device spicevmc */
if (!qemuCapsGet(flags, QEMU_CAPS_CHARDEV_SPICEVMC) &&
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ae3de90..1e23451 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -113,6 +113,7 @@ enum qemuCapsFlags {
QEMU_CAPS_NO_SHUTDOWN = 74, /* usable -no-shutdown */
QEMU_CAPS_DRIVE_CACHE_UNSAFE = 75, /* Is cache=unsafe supported? */
+ QEMU_CAPS_ICH9_AHCI = 76, /* -device ich9-ahci */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9174a5f..6d6e67d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1702,6 +1702,12 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
disk->info.addr.drive.bus,
disk->info.addr.drive.unit);
break;
+ case VIR_DOMAIN_DISK_BUS_SATA:
+ virBufferAddLit(&opt, "ide-drive");
+ virBufferAsprintf(&opt, ",bus=ahci%d.%d",
+ disk->info.addr.drive.controller,
+ disk->info.addr.drive.unit);
+ break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
virBufferAddLit(&opt, "virtio-blk-pci");
qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps);
@@ -1902,6 +1908,10 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def,
virBufferAsprintf(&buf, "usb-ccid,id=ccid%d", def->idx);
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
+ virBufferAsprintf(&buf, "ahci,id=ahci%d", def->idx);
+ break;
+
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
if (qemuBuildUSBControllerDevStr(def, qemuCaps, &buf) == -1)
goto error;
@@ -3683,14 +3693,22 @@ qemuBuildCommandLine(virConnectPtr conn,
cont->type == VIR_DOMAIN_CONTROLLER_TYPE_FDC)
continue;
- /* QEMU doesn't implement a SATA driver */
+ /* Only recent QEMU implements a SATA (AHCI) controller */
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
- qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("SATA is not supported with this
QEMU binary"));
- goto error;
- }
+ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("SATA is not supported with
this QEMU binary"));
+ goto error;
+ } else {
+ char *devstr;
- if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB
&&
+ virCommandAddArg(cmd, "-device");
+ if (!(devstr = qemuBuildControllerDevStr(cont, qemuCaps, NULL)))
+ goto error;
+
+ virCommandAddArg(cmd, devstr);
+ }
+ } else if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB
&&
def->controllers[i]->model == -1 &&
!qemuCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) {
if (usblegacy) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.args
new file mode 100644
index 0000000..9908da6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device ahci,id=ahci0,\
+bus=pci.0,addr=0x3 -drive file=/dev/HostVG/QEMUGuest1,if=none,\
+id=drive-sata0-0-0 -device ide-drive,bus=ahci0.0,drive=drive-sata0-0-0,\
+id=sata0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.xml
b/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.xml
new file mode 100644
index 0000000..68a14f2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.xml
@@ -0,0 +1,25 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9e174b3..f298d37 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -359,6 +359,9 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-device-auto", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("disk-sata-device", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE,
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI);
DO_TEST("disk-aio", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_AIO,
QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
--
1.7.5.4
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
--
Adam Litke
IBM Linux Technology Center
--
libvir-list mailing list
libvir-list(a)redhat.com