* [Qemu-devel] [PATCH v2 1/2] igd-passthrough-i440FX: convert to realize()
@ 2015-12-21 11:00 Cao jin
2015-12-23 8:49 ` Cao jin
0 siblings, 1 reply; 3+ messages in thread
From: Cao jin @ 2015-12-21 11:00 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, ehabkost, armbru
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
hw/pci-host/piix.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 715208b..bc0fc59 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -761,7 +761,7 @@ static const IGDHostInfo igd_host_bridge_infos[] = {
{0xa8, 4}, /* SNB: base of GTT stolen memory */
};
-static int host_pci_config_read(int pos, int len, uint32_t val)
+static void host_pci_config_read(int pos, int len, uint32_t val, Error **errp)
{
char path[PATH_MAX];
int config_fd;
@@ -769,50 +769,52 @@ static int host_pci_config_read(int pos, int len, uint32_t val)
/* Access real host bridge. */
int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",
0, 0, 0, 0, "config");
- int ret = 0;
if (rc >= size || rc < 0) {
- return -ENODEV;
+ error_setg_errno(errp, errno, "snprintf err");
+ return;
}
config_fd = open(path, O_RDWR);
if (config_fd < 0) {
- return -ENODEV;
+ error_setg_errno(errp, errno, "open err");
+ return;
}
if (lseek(config_fd, pos, SEEK_SET) != pos) {
- ret = -errno;
+ error_setg_errno(errp, errno, "lseek err");
goto out;
}
+
do {
rc = read(config_fd, (uint8_t *)&val, len);
} while (rc < 0 && (errno == EINTR || errno == EAGAIN));
if (rc != len) {
- ret = -errno;
+ error_setg_errno(errp, errno, "read err");
}
+
out:
close(config_fd);
- return ret;
}
-static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
+static void igd_pt_i440fx_realize(struct PCIDevice *pci_dev, Error **errp)
{
uint32_t val = 0;
- int rc, i, num;
+ int i, num;
int pos, len;
+ Error *local_err = NULL;
num = ARRAY_SIZE(igd_host_bridge_infos);
for (i = 0; i < num; i++) {
pos = igd_host_bridge_infos[i].offset;
len = igd_host_bridge_infos[i].len;
- rc = host_pci_config_read(pos, len, val);
- if (rc) {
- return -ENODEV;
+ host_pci_config_read(pos, len, val, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
}
pci_default_write_config(pci_dev, pos, val, len);
}
-
- return 0;
}
static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
@@ -820,7 +822,7 @@ static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- k->init = igd_pt_i440fx_initfn;
+ k->realize = igd_pt_i440fx_realize;
dc->desc = "IGD Passthrough Host bridge";
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] igd-passthrough-i440FX: convert to realize()
2015-12-21 11:00 [Qemu-devel] [PATCH v2 1/2] igd-passthrough-i440FX: convert to realize() Cao jin
@ 2015-12-23 8:49 ` Cao jin
2016-01-04 15:30 ` Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Cao jin @ 2015-12-23 8:49 UTC (permalink / raw)
To: mst; +Cc: armbru, qemu-devel, ehabkost
Hi mst,
Ping
Or do I need to cc this to qemu-trivial?
On 12/21/2015 07:00 PM, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> hw/pci-host/piix.c | 32 +++++++++++++++++---------------
> 1 file changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 715208b..bc0fc59 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -761,7 +761,7 @@ static const IGDHostInfo igd_host_bridge_infos[] = {
> {0xa8, 4}, /* SNB: base of GTT stolen memory */
> };
>
> -static int host_pci_config_read(int pos, int len, uint32_t val)
> +static void host_pci_config_read(int pos, int len, uint32_t val, Error **errp)
> {
> char path[PATH_MAX];
> int config_fd;
> @@ -769,50 +769,52 @@ static int host_pci_config_read(int pos, int len, uint32_t val)
> /* Access real host bridge. */
> int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",
> 0, 0, 0, 0, "config");
> - int ret = 0;
>
> if (rc >= size || rc < 0) {
> - return -ENODEV;
> + error_setg_errno(errp, errno, "snprintf err");
> + return;
> }
>
> config_fd = open(path, O_RDWR);
> if (config_fd < 0) {
> - return -ENODEV;
> + error_setg_errno(errp, errno, "open err");
> + return;
> }
>
> if (lseek(config_fd, pos, SEEK_SET) != pos) {
> - ret = -errno;
> + error_setg_errno(errp, errno, "lseek err");
> goto out;
> }
> +
> do {
> rc = read(config_fd, (uint8_t *)&val, len);
> } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
> if (rc != len) {
> - ret = -errno;
> + error_setg_errno(errp, errno, "read err");
> }
> +
> out:
> close(config_fd);
> - return ret;
> }
>
> -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
> +static void igd_pt_i440fx_realize(struct PCIDevice *pci_dev, Error **errp)
> {
> uint32_t val = 0;
> - int rc, i, num;
> + int i, num;
> int pos, len;
> + Error *local_err = NULL;
>
> num = ARRAY_SIZE(igd_host_bridge_infos);
> for (i = 0; i < num; i++) {
> pos = igd_host_bridge_infos[i].offset;
> len = igd_host_bridge_infos[i].len;
> - rc = host_pci_config_read(pos, len, val);
> - if (rc) {
> - return -ENODEV;
> + host_pci_config_read(pos, len, val, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + return;
> }
> pci_default_write_config(pci_dev, pos, val, len);
> }
> -
> - return 0;
> }
>
> static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
> @@ -820,7 +822,7 @@ static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> - k->init = igd_pt_i440fx_initfn;
> + k->realize = igd_pt_i440fx_realize;
> dc->desc = "IGD Passthrough Host bridge";
> }
>
>
--
Yours Sincerely,
Cao Jin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] igd-passthrough-i440FX: convert to realize()
2015-12-23 8:49 ` Cao jin
@ 2016-01-04 15:30 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2016-01-04 15:30 UTC (permalink / raw)
To: Cao jin; +Cc: qemu-devel, armbru, ehabkost, mst
On Mi, 2015-12-23 at 16:49 +0800, Cao jin wrote:
> Hi mst,
> Ping
> Or do I need to cc this to qemu-trivial?
FYI: I have a pending series which reworks all these igd bits, fixing a
bunch of other issues (beside error reporting) along the way.
https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg02129.html
Feel free to review to help getting them in ;)
cheers,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-04 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 11:00 [Qemu-devel] [PATCH v2 1/2] igd-passthrough-i440FX: convert to realize() Cao jin
2015-12-23 8:49 ` Cao jin
2016-01-04 15:30 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.