From patchwork Thu Mar 7 17:29:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1053123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JPjP5JxB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44FdSc2Z0rz9sNB for ; Fri, 8 Mar 2019 04:50:08 +1100 (AEDT) Received: from localhost ([127.0.0.1]:56337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1x9i-0001OF-C6 for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2019 12:50:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wqW-0002sN-Ip for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wqV-0007sT-4K for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:16 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:53656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wqU-0007rY-My for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:15 -0500 Received: by mail-wm1-x32c.google.com with SMTP id e74so10066371wmg.3 for ; Thu, 07 Mar 2019 09:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4f96miqlDQnqH5jBEIDnorZ6/qIF6M4o3BxJP/ggJwU=; b=JPjP5JxB/FzmYvtcViJt58/VkmA3pivWF3q9YfGuzaQfqYJBuHOlwarVQYuV6EMKYV qDMJa1MQIdnPf/epFHyWKW1Dx2VsSTR1mTc/a4fWEypveo5P/leMqpP5hy/B+uHKLqzm fgrbgaFvvoKa3ZI+6I1MIegiX4ihKEqcRmPBcLpsOwymvvyuz1a6OiPONDQ6EF4iSXx+ ojsa9AvQB9c3Ji8hxdmAOo4wCdJZ7+DWsVGgnrkFBVUsfnGQpmvn7Ye8V2bPP2O9rrDI wMl6dXhu1IetGh9dxyLcEzf02mWJgL1FcXmTTCurJP9voqE2vIW9s381HqyDsCgso7MW Wz9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4f96miqlDQnqH5jBEIDnorZ6/qIF6M4o3BxJP/ggJwU=; b=CBaQdqdloAu6f/rdiPL5KmNxmB28Q9VvsWlyCl4VuVz5r9QrEJlI1RXt6Q7LwNIA7h /XflAXATVkUEG2uAqHK6Q1yajV/b7ONr73BfSQSeSUdfDJZM//VBpbARP04s9en0CcyT O5E2JZEM7G+4jhza8iF25VecMl62JpgCi0Kxz1Adrp95B3+v0KrD5Af5vuEWUmhOS7TA GOXAI01i25Cjd4dbNWKBVLj27hokuudspkmMAr2S8npRex60W7mrdHtmL8OyAyGFt2Fb NunxIJR4lLm6/7G8zyiGrOAGb4b2cV/zclj3880zyDDRwvAwm2JRgIcuu84UbIMeox33 Lf3A== X-Gm-Message-State: APjAAAVzTgi4XP4SKPitWfpFwTQW8ohDz8sChoQSQs72r3YHfOr/Hmc1 BubScKrrcY9uHykE7YjW4rhxBeWh X-Google-Smtp-Source: APXvYqw15Rgjg2om337EBVavm2cZKrAHoJ/NhQdcM6sdDmevO1PpmULS4pfr/ynPl64fYV9gzLU0jw== X-Received: by 2002:a7b:c94c:: with SMTP id i12mr6324736wml.2.1551979813228; Thu, 07 Mar 2019 09:30:13 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:14 +0100 Message-Id: <1551979804-6060-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c Subject: [Qemu-devel] [PULL 07/57] tests/libqos: x86_64/pc machine node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Emanuele Giuseppe Esposito , lviver@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Emanuele Giuseppe Esposito Add pc machine for the x86_64 QEMU binary. This machine contains an i440FX-pcihost driver, that contains itself a pci-bus-pc that produces the pci-bus interface. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 3 ++ tests/libqos/x86_64_pc-machine.c | 114 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 tests/libqos/x86_64_pc-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 5a7ea15..8a760bd 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -753,6 +753,9 @@ libqos-virtio-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/virt qos-test-obj-y = tests/qos-test.o $(libqgraph-obj-y) qos-test-obj-y += $(libqos-pc-obj-y) +# Machines +qos-test-obj-y += tests/libqos/x86_64_pc-machine.o + check-unit-y += tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) diff --git a/tests/libqos/x86_64_pc-machine.c b/tests/libqos/x86_64_pc-machine.c new file mode 100644 index 0000000..8bd0360 --- /dev/null +++ b/tests/libqos/x86_64_pc-machine.c @@ -0,0 +1,114 @@ +/* + * libqos driver framework + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "libqos/qgraph.h" +#include "pci-pc.h" +#include "malloc-pc.h" + +typedef struct QX86PCMachine QX86PCMachine; +typedef struct i440FX_pcihost i440FX_pcihost; +typedef struct QSDHCI_PCI QSDHCI_PCI; + +struct i440FX_pcihost { + QOSGraphObject obj; + QPCIBusPC pci; +}; + +struct QX86PCMachine { + QOSGraphObject obj; + QGuestAllocator alloc; + i440FX_pcihost bridge; +}; + +/* i440FX_pcihost */ + +static QOSGraphObject *i440FX_host_get_device(void *obj, const char *device) +{ + i440FX_pcihost *host = obj; + if (!g_strcmp0(device, "pci-bus-pc")) { + return &host->pci.obj; + } + fprintf(stderr, "%s not present in i440FX-pcihost\n", device); + g_assert_not_reached(); +} + +static void qos_create_i440FX_host(i440FX_pcihost *host, + QTestState *qts, + QGuestAllocator *alloc) +{ + host->obj.get_device = i440FX_host_get_device; + qpci_init_pc(&host->pci, qts, alloc); +} + +/* x86_64/pc machine */ + +static void pc_destructor(QOSGraphObject *obj) +{ + QX86PCMachine *machine = (QX86PCMachine *) obj; + alloc_destroy(&machine->alloc); +} + +static void *pc_get_driver(void *object, const char *interface) +{ + QX86PCMachine *machine = object; + if (!g_strcmp0(interface, "memory")) { + return &machine->alloc; + } + + fprintf(stderr, "%s not present in x86_64/pc\n", interface); + g_assert_not_reached(); +} + +static QOSGraphObject *pc_get_device(void *obj, const char *device) +{ + QX86PCMachine *machine = obj; + if (!g_strcmp0(device, "i440FX-pcihost")) { + return &machine->bridge.obj; + } + + fprintf(stderr, "%s not present in x86_64/pc\n", device); + g_assert_not_reached(); +} + +static void *qos_create_machine_pc(QTestState *qts) +{ + QX86PCMachine *machine = g_new0(QX86PCMachine, 1); + machine->obj.get_device = pc_get_device; + machine->obj.get_driver = pc_get_driver; + machine->obj.destructor = pc_destructor; + pc_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS); + qos_create_i440FX_host(&machine->bridge, qts, &machine->alloc); + + return &machine->obj; +} + +static void pc_machine_register_nodes(void) +{ + qos_node_create_machine("i386/pc", qos_create_machine_pc); + qos_node_contains("i386/pc", "i440FX-pcihost", NULL); + + qos_node_create_machine("x86_64/pc", qos_create_machine_pc); + qos_node_contains("x86_64/pc", "i440FX-pcihost", NULL); + + qos_node_create_driver("i440FX-pcihost", NULL); + qos_node_contains("i440FX-pcihost", "pci-bus-pc", NULL); +} + +libqos_init(pc_machine_register_nodes);