From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887472; cv=none; d=zohomail.com; s=zohoarc; b=B8nw7efy2KbdEMyVKGFtX4thoCeAEkntbuczMNCYKGRA82loDVXRNw2bYoablhzOTLDZynKWcARpB3KWBGaiUT/9lADD2+AQXie8ZYtcfP5JkRMw8NAhx7XUFVeC68re+i30HTLtPmAumNm41X0ZSmnm/Sd6kw8ft7zGG8lE/70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887472; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kwK+YtoN3ISvSonZG8pWmnKbUjP97LUVMTrPci50qGM=; b=ik47cRDF3djJm8nBD7Gc6AfHMeSQPjuubkeEcmCNCkAws9fC37l1HG1g63JYsZYscQ9gCpfRt1GSaC+ptQ1Qwe+WH9QxEXoclsabcSl0D6EtC4g9R5Lh2GEXEfLmybpIDjloJ9MXYJXlNGsXLxC7OuTr5DJXp1C6YrFe5innmzM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887472342517.3397083460453; Sat, 4 Jul 2020 11:31:12 -0700 (PDT) Received: from localhost ([::1]:59196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmwQ-0004cw-Um for importer@patchew.org; Sat, 04 Jul 2020 14:31:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvA-0002jG-Cs for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36346 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmuq-0001I2-8O for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:52 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-iLM0IORvP-mCWBxMxLk9cA-1; Sat, 04 Jul 2020 14:29:29 -0400 Received: by mail-wr1-f72.google.com with SMTP id d11so18926535wrw.12 for ; Sat, 04 Jul 2020 11:29:29 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id c11sm16764510wmb.45.2020.07.04.11.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kwK+YtoN3ISvSonZG8pWmnKbUjP97LUVMTrPci50qGM=; b=UjWEb9vekL43tkOZmb/O4s1CzGV4doJSeBzQnpx6XU1QOmq7p6AnWZ03K7xrelejj13gOb M/O7JD2ZzkV8xMz7c6MkbCy16BW2Bp17ImnPEbDlEkwtEsQ19oKWc1caPP2PCPRYYF6QLz q/7i/QyuIUcFvN0sXU9zBQe/Q7Fumx4= X-MC-Unique: iLM0IORvP-mCWBxMxLk9cA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kwK+YtoN3ISvSonZG8pWmnKbUjP97LUVMTrPci50qGM=; b=pNkas4nMATVznWYmyTy0jymvhU0BUnxIPjIo0xd3/EeUhJK3Zr51J9qPrHK/LLGMjw vAhPO6/k3AQ38M/Dz55cS820xwS/iV1fKz52h9W6GJHS0Usxxlkcrqkg6+2pSq8fkSE+ 764hNnSwMeN+9IlSC/HHaUHQrnzeL+H/nKSHJvzZlvhjB0FPJgQsEZ1yvhqX+HHYiT0W iJz7gpq3QOoWLDJ4RCP5SYaFgm7cJLyOESsEOmd65871YmUBD0nA8T7ZCisqmFUQbpSK m8H3Iq3L2eVMYPgH4dvRLE1rN0mQO0rhO8ESnh/5TIiXj5B5OTYVVUYE3h0G8cbMckJd xZdQ== X-Gm-Message-State: AOAM530wMM8a4fHq6iuorhVvtIlJQCpo1U3YaI4G9QqQfKJaXlsu2jeO G7cRrL4Aw1+V/gXICyknRHzqjIaLNfMttiI0OFXk1mA+cNApkQsBB2SIC256mvPjbg0yifb6eL9 SAK4vbv+MB7+VQ1o= X-Received: by 2002:a7b:c94a:: with SMTP id i10mr18599107wml.183.1593887367709; Sat, 04 Jul 2020 11:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt0y7gHWJp9A2EIGhHYdo5s+mqBkChaOATIHmPLhIaZpHaTCjIzsPNPsHTRkp2srZxgMMPVg== X-Received: by 2002:a7b:c94a:: with SMTP id i10mr18599085wml.183.1593887367342; Sat, 04 Jul 2020 11:29:27 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 01/41] tests: disassemble-aml.sh: generate AML in readable format Message-ID: <20200704182750.1088103-2-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On systems where the IASL tool exists, we can convert extected ACPI tables to ASL format, which is useful for debugging and documentation purposes. This script does this for all ACPI tables under tests/data/acpi/. Signed-off-by: Michael S. Tsirkin --- tests/data/acpi/disassemle-aml.sh | 52 +++++++++++++++++++++++++ tests/data/acpi/rebuild-expected-aml.sh | 1 + 2 files changed, 53 insertions(+) create mode 100755 tests/data/acpi/disassemle-aml.sh diff --git a/tests/data/acpi/disassemle-aml.sh b/tests/data/acpi/disassemle= -aml.sh new file mode 100755 index 0000000000..1d8a4d0301 --- /dev/null +++ b/tests/data/acpi/disassemle-aml.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +outdir=3D +while getopts "o:" arg; do + case ${arg} in + o ) + outdir=3D$OPTARG + ;; + \? ) + echo "Usage: ./tests/data/acpi/disassemle-aml.sh [-o ]" + exit 1 + ;; + + esac +done + +for machine in tests/data/acpi/* +do + if [[ ! -d "$machine" ]]; + then + continue + fi + + if [[ "${outdir}" ]]; + then + mkdir -p "${outdir}"/${machine} || exit $? + fi + for aml in $machine/* + do + if [[ "$aml" =3D=3D $machine/*.dsl ]]; + then + continue + fi + if [[ "$aml" =3D=3D $machine/SSDT*.* ]]; + then + dsdt=3D${aml/SSDT*./DSDT.} + extra=3D"-e ${dsdt}" + elif [[ "$aml" =3D=3D $machine/SSDT* ]]; + then + dsdt=3D${aml/SSDT*/DSDT}; + extra=3D"-e ${dsdt}" + else + extra=3D"" + fi + asl=3D${aml}.dsl + if [[ "${outdir}" ]]; + then + asl=3D"${outdir}"/${machine}/${asl} + fi + iasl -d -p ${asl} ${extra} ${aml} + done +done diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebu= ild-expected-aml.sh index 9cbaab1a4d..76cd797d1e 100755 --- a/tests/data/acpi/rebuild-expected-aml.sh +++ b/tests/data/acpi/rebuild-expected-aml.sh @@ -36,6 +36,7 @@ old_allowed_dif=3D`grep -v -e 'List of comma-separated ch= anged AML files to ignore echo '/* List of comma-separated changed AML files to ignore */' > ${SRC_P= ATH}/tests/qtest/bios-tables-test-allowed-diff.h =20 echo "The files were rebuilt and can be added to git." +echo "You can use ${SRC_PATH}/tests/data/acpi/disassemle-aml.sh to disasse= mble them to ASL." =20 if [ -z "$old_allowed_dif" ]; then echo "Note! Please do not commit expected files with source changes" --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887600; cv=none; d=zohomail.com; s=zohoarc; b=kuag8/jVigMHkQiHzw8nWb30DX12liqjYw7QrJDFtunMjuIFDdhELXVt9yLoYKrw0EZoWv1D8ZiojxocW2YFLm1S+om83tOXX/AFvCEdTsaF2hvgTAvaDLDIfXGnpr0mi8pfkWgSQ3Fd+losOOw6erhekIIRq3YuchEYVbhG2OI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AZqj3bTam91VJKMgXj5mJaby8iNVg3MqxY1e+jpggf8=; b=UnyFh1lPrhA/DtEHOzMcbDR9S9HRGQXFGBKpslS6FnJySr8SbBK5TmfCruFY/45We00bvBBB76vEgwJqwXQTTUaxrp9rEtB54fcCdoJ7Q0WBh8avPK8XxNDp91LmGC7TqEo7SzVYeKbevaCmt7Lzk39UAwytiOqtPDryISmUpt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887600231116.98570237590718; Sat, 4 Jul 2020 11:33:20 -0700 (PDT) Received: from localhost ([::1]:38994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmyU-0007tt-UA for importer@patchew.org; Sat, 04 Jul 2020 14:33:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmuw-0002bQ-0I for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:38 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25977 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmuu-0001IH-DP for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:37 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-Zlir96KaP_Ka9eOGpHsFjg-1; Sat, 04 Jul 2020 14:29:32 -0400 Received: by mail-wr1-f69.google.com with SMTP id e11so36458936wrs.2 for ; Sat, 04 Jul 2020 11:29:31 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id j15sm8656956wrx.69.2020.07.04.11.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AZqj3bTam91VJKMgXj5mJaby8iNVg3MqxY1e+jpggf8=; b=NHra7ET9G5+qx5yleOxYt/Qb15ad6AO4UgQNTozLH0663kwOHOVMbyk5wV/19fIy7ysF/T EOzFTOvHiFceyhvePkha9g0gMelpvb/ROUSPBsSEt50ji7xvwls1dR2WbScbrbWjOWww3P WMfxhX4hklKTzLB3lYyOUi/dD1ybDVc= X-MC-Unique: Zlir96KaP_Ka9eOGpHsFjg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=AZqj3bTam91VJKMgXj5mJaby8iNVg3MqxY1e+jpggf8=; b=oU/3ui8nNztknGikUU8r0WGuusDt/OzPuAQp9FQqnIUGp4ntxyQU48HX8iFiV44i0+ ByIqXi+ZZ21h62TaTSIYn/078G0tj09zWxR+mhnF40LvG9l+y2QewS6nMTShQWkAa8Hj WW+1aj8T5eEmweGXwq92M+sBzdoGr0dyBhT+6nr1hTWvusTQF1LPSBsz4QYwV8q6m9Mm dk1ZD49dvXi9ap26h7txLqc1MDTdwzl1ZqT3rs3jU+mVhO0QdU9tQT61W1O0JDdunSaO 0cGEYnbq/L9nmlMR2r/3ZjaDaKJs0le2eGtafNGqJaLdpA0wVPCOTB5nEaIeFCfjsEae rgpQ== X-Gm-Message-State: AOAM530pNuBYfRc6tTKJuxPaOulD7Ns3hQF4zmnZ9lThmuuOAjEFZvUN VD8x9e49xzQfW9b0jCBlDVeEQG0YYJ0nShDQKw3NBVwfWF4NXQE1yZHc8IXX8zvc1cobCId+X2+ xq1/VQeo3EbZQQVs= X-Received: by 2002:a7b:c403:: with SMTP id k3mr37895742wmi.35.1593887370310; Sat, 04 Jul 2020 11:29:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy1KiF1TbW4Vvp2AgUuk6Td4M2xK/Cf2znN9w9drf2fO/hzzSs8kXo/tFL0CgvJqycCmPvPQ== X-Received: by 2002:a7b:c403:: with SMTP id k3mr37895729wmi.35.1593887370142; Sat, 04 Jul 2020 11:29:30 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 02/41] Revert "tests/migration: Reduce autoconverge initial bandwidth" Message-ID: <20200704182750.1088103-3-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Juan Quintela , "Dr . David Alan Gilbert" , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This reverts commit 6d1da867e65f ("tests/migration: Reduce autoconverge ini= tial bandwidth") since that change makes unit tests much slower for all developers, while it= 's not a robust way to fix migration tests. Migration tests need to find a more robust way to discover a reasonable bandwidth without slowing things down for everyone. Fixes: 6d1da867e65f ("tests/migration: Reduce autoconverge initial bandwidt= h") Signed-off-by: Michael S. Tsirkin Acked-by: Dr. David Alan Gilbert Acked-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Thomas Huth --- tests/qtest/migration-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index dc3490c9fa..21ea5ba1d2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1211,7 +1211,7 @@ static void test_migrate_auto_converge(void) * without throttling. */ migrate_set_parameter_int(from, "downtime-limit", 1); - migrate_set_parameter_int(from, "max-bandwidth", 1000000); /* ~1Mb/s */ + migrate_set_parameter_int(from, "max-bandwidth", 100000000); /* ~100Mb= /s */ =20 /* To check remaining size after precopy */ migrate_set_capability(from, "pause-before-switchover", true); --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887468; cv=none; d=zohomail.com; s=zohoarc; b=Ido+jXxThbPt1mGwhSe5JMLuzrrYW7pBtXRldP/7px5tElKQGqOlJKzlpkwY1fPp4AAqDpdzhXgd8eemfEAcYu6nM6BIH7HG/pWjAWC53N+8BgkUpxfvOAM5kW0rTcTCGjm3oCx9u4o6BSr56OUIhLSoY7n/BDazOmJWtj2/dug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887468; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3SejujQmFP8i9uGegxOHZH22A3MzEqNQC/7kkGUHxhs=; b=UXX1yZDr0xgRa8eHcQLEW8JnMRra3DgCehpbSN2zuQjd1cZUfEhNQRk+/+rxJgKsFyWCr4k7dVdwDflyI7lcEGFk0WiCqahh9ciGWzh4tQguS81+kps31VPaDq16tOTbYwT8aAPvoavNDSQrOoKqLwQT7rIPv6NOgnF/9qEWpCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887468739138.2741893340201; Sat, 4 Jul 2020 11:31:08 -0700 (PDT) Received: from localhost ([::1]:58896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmwN-0004V9-BI for importer@patchew.org; Sat, 04 Jul 2020 14:31:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmuw-0002cC-Mq for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:38 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:28338 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmuu-0001IZ-T5 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:38 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-kvLc4tTkMyG7L9CYslksHQ-1; Sat, 04 Jul 2020 14:29:34 -0400 Received: by mail-wr1-f69.google.com with SMTP id o25so36282838wro.16 for ; Sat, 04 Jul 2020 11:29:34 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 190sm5442856wmb.15.2020.07.04.11.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3SejujQmFP8i9uGegxOHZH22A3MzEqNQC/7kkGUHxhs=; b=DdFjCgsEepdeRuRskf9oEIunqTOqZjxjMz25dFMzZeiYiPRH9TTDyFhDFbx/a6HZN7F2rQ wZXVYpxbHe3kaC0iTc94rNcR0DhNdyiRLgD+DbsgeKN3+Iwwb80UibivtMFDOATUm54vLz Eb2oEx+ZY6GjKwrqxfNxDDW71/gPbDY= X-MC-Unique: kvLc4tTkMyG7L9CYslksHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3SejujQmFP8i9uGegxOHZH22A3MzEqNQC/7kkGUHxhs=; b=WFegdPxggmgb+KtNxi9UYDFvJgBsgQGUOHw6ZfwF51PuInnSphiBOZZFLdMJ6LcqvI vUiGc2GwCqY/HAQg/6UhH91aM6Ad2P4oRYcltlxqMZbQdvgFaDZPERiRYASphX1PmX7l z/LEQBUAl/VDSnuuXiO096ypwzmPA7R8yHYXlZd0dQOnJaByEZMp8RXaz6pkqWFJnqDD TYLUBgyT4YGUXi5OfwhDPF80YOVK/BZKyxdGg7z82LctVycWvt+aQIOclAKlN2AVNg0s P23dw+j6bwbybVs+dAEshBRoKkz1oPEpcYJ/FyYp/vqo9VyQMHk48U/Sbjo5HHkpGy5r 2UKQ== X-Gm-Message-State: AOAM5321uFiid9MxwCJfGY1M0q/EV7tfzH+JidIMm9e4JfLqLmujNgrl nz9s5Pv21z/tFS3n8yBaSyHSEvKZphp7tp33nNU44DtPnVwbc7wJdgMrWKBqqOUHCDnimH/lIfq +CnjwlCJAZMAQMJo= X-Received: by 2002:adf:fe85:: with SMTP id l5mr39581540wrr.333.1593887372917; Sat, 04 Jul 2020 11:29:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl7cC5HFtxklJWiLlUrG+mOqBn8iRF97gmoUQxr/9BjLTgrbk7C+zAbM7yDMq0iARg8U2bXQ== X-Received: by 2002:adf:fe85:: with SMTP id l5mr39581530wrr.333.1593887372687; Sat, 04 Jul 2020 11:29:32 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 03/41] virtio-balloon: always indicate S_DONE when migration fails Message-ID: <20200704182750.1088103-4-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alexander Duyck , Wei Wang , Alexander Duyck , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand If something goes wrong during precopy, before stopping the VM, we will never send a S_DONE indication to the VM, resulting in the hinted pages not getting released to be used by the guest OS (e.g., Linux). Easy to reproduce: 1. Start migration (e.g., HMP "migrate -d 'exec:gzip -c > STATEFILE.gz'") 2. Cancel migration (e.g., HMP "migrate_cancel") 3. Oberve in the guest (e.g., cat /proc/meminfo) that there is basically no free memory left. While at it, add similar locking to virtio_balloon_free_page_done() as done in virtio_balloon_free_page_stop. Locking is still weird, but that has to be sorted out separately. There is nothing to do in the PRECOPY_NOTIFY_COMPLETE case. Add some comments regarding S_DONE handling. Fixes: c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Reviewed-by: Alexander Duyck Cc: Wei Wang Cc: Alexander Duyck Signed-off-by: David Hildenbrand Message-Id: <20200629080615.26022-1-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 10507b2a43..8a84718490 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -628,8 +628,13 @@ static void virtio_balloon_free_page_done(VirtIOBalloo= n *s) { VirtIODevice *vdev =3D VIRTIO_DEVICE(s); =20 - s->free_page_report_status =3D FREE_PAGE_REPORT_S_DONE; - virtio_notify_config(vdev); + if (s->free_page_report_status !=3D FREE_PAGE_REPORT_S_DONE) { + /* See virtio_balloon_free_page_stop() */ + qemu_mutex_lock(&s->free_page_lock); + s->free_page_report_status =3D FREE_PAGE_REPORT_S_DONE; + qemu_mutex_unlock(&s->free_page_lock); + virtio_notify_config(vdev); + } } =20 static int @@ -653,17 +658,26 @@ virtio_balloon_free_page_report_notify(NotifierWithRe= turn *n, void *data) case PRECOPY_NOTIFY_SETUP: precopy_enable_free_page_optimization(); break; - case PRECOPY_NOTIFY_COMPLETE: - case PRECOPY_NOTIFY_CLEANUP: case PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC: virtio_balloon_free_page_stop(dev); break; case PRECOPY_NOTIFY_AFTER_BITMAP_SYNC: if (vdev->vm_running) { virtio_balloon_free_page_start(dev); - } else { - virtio_balloon_free_page_done(dev); + break; } + /* + * Set S_DONE before migrating the vmstate, so the guest will reuse + * all hinted pages once running on the destination. Fall through. + */ + case PRECOPY_NOTIFY_CLEANUP: + /* + * Especially, if something goes wrong during precopy or if migrat= ion + * is canceled, we have to properly communicate S_DONE to the VM. + */ + virtio_balloon_free_page_done(dev); + break; + case PRECOPY_NOTIFY_COMPLETE: break; default: virtio_error(vdev, "%s: %d reason unknown", __func__, pnd->reason); --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887599; cv=none; d=zohomail.com; s=zohoarc; b=fcZjqtK4kGNn8LsrZsxP+a7vHdfdY2ipSRspfxqQzAtBG+heCJ+w++BmOYBlsCo2WhcKGoZ8XjW6bOuuIbcY4iLikv6ho7FL9m5Y0yWLo7m73nGPGqSrRlgqoe9Sglf1/kDEns9pn2tyW+wyH7JE4toXJ0G3NwbijxLV+Lc59jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887599; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zAm2WZsz8jFA4V7I3jZT5e4XH4Wdo1IJW/sufln0SFE=; b=bGqYWlyuR85l1Yod+RTLTgCmKfiF47MNhnWzCZOd68jz7d644wWlI4xweoPjYt8HqGc33JeESB7+Jv56Kc+ShZYzYyxdIHoFBLrRIP9bq1dAjAcB9Xxg2S/G6CRuhqUNKCPrdXVXArcg1lKesZZbf5p+EcCDCi6j0fBfb2zjTsk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887599258635.7037201775447; Sat, 4 Jul 2020 11:33:19 -0700 (PDT) Received: from localhost ([::1]:38852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmyU-0007qS-1h for importer@patchew.org; Sat, 04 Jul 2020 14:33:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmv0-0002es-0W for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:42 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:49091 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmux-0001Is-HP for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:41 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-r5BGi9uUMhmtKJM7Lpb6Mw-1; Sat, 04 Jul 2020 14:29:36 -0400 Received: by mail-wr1-f69.google.com with SMTP id y13so36372883wrp.13 for ; Sat, 04 Jul 2020 11:29:36 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id k11sm19031491wrd.23.2020.07.04.11.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zAm2WZsz8jFA4V7I3jZT5e4XH4Wdo1IJW/sufln0SFE=; b=itoGwq0YcoOjKl/jEqZToFwU9GK9VeCVIAF/TscmnvEUWmyn3dj/SqBmf/RXBxZzhA+u3P t9XHUvLI3cBI2usxnhg/F495J6x7vm6umIsD9b2cI4HsDG82X3dBq6Zl2qUPOAzImqDjRX ddZLiVGtfyndv6zsNzBYbMxkEn4ndoM= X-MC-Unique: r5BGi9uUMhmtKJM7Lpb6Mw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zAm2WZsz8jFA4V7I3jZT5e4XH4Wdo1IJW/sufln0SFE=; b=juvjcO0knz32VdnGfKHJjZubQZT3eg897/DyZWW8LX5Uic3pGJRCndvm3mpzmh4oJX IVoEV9AdhKnHK4quDwKZsvrk8P6TagL1MTJJLqvmNqdXWxFReZS01X0otSG15WMau4ki Ax44bsbJREysIbQycXXXE6Z1ELgzOpHam+lIUHc13+bWdu0qXsCqO+ZhXIBmkRry8ynF ZxZBEh7T2WcgyhoWJTiJd/YLi0Jeqyx/Rcfl7GpFywyMfqt/yEAN6x9ri3YMtx+pZlKJ DH+UY9Jpa9sbJBZvPlwmJOVimWxU2ONqvDJ34uEmdNkQ4nmY3XZF26dFJDomWlaftJhW p1VA== X-Gm-Message-State: AOAM533eG48A/7rH9bt/LvD2fGBKEuEfSET+ZdpzqP1A95fDqarr7koQ NN/vbt9w2NzkeTqzXrPhiaXkjJg9WN2Gq+WHxrdAjesovEYNbi94KbsHWLITkrKLDe+02SE1EM8 0a7HTAq8V8oKTHTY= X-Received: by 2002:adf:fa81:: with SMTP id h1mr43872385wrr.288.1593887375635; Sat, 04 Jul 2020 11:29:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPT2IaD1JL44r79iuBa7ESJw3EaC1FsfABCBydH/JVo1xurbkbMytgYPHmjg3qW+zJ/XKFew== X-Received: by 2002:adf:fa81:: with SMTP id h1mr43872369wrr.288.1593887375433; Sat, 04 Jul 2020 11:29:35 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 04/41] pc: Support coldplugging of virtio-pmem-pci devices on all buses Message-ID: <20200704182750.1088103-5-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Pankaj Gupta , David Hildenbrand , Paolo Bonzini , Igor Mammedov , Vivek Goyal , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand E.g., with "pc-q35-4.2", trying to coldplug a virtio-pmem-pci devices results in "virtio-pmem-pci not supported on this bus" Reasons is, that the bus does not support hotplug and, therefore, does not have a hotplug handler. Let's allow coldplugging virtio-pmem devices on such buses. The hotplug order is only relevant for virtio-pmem-pci when the guest is already alive and the device is visible before memory_device_plug() wired up the memory device bits. Hotplug attempts will still fail with: "Error: Bus 'pcie.0' does not support hotplugging" Hotunplug attempts will still fail with: "Error: Bus 'pcie.0' does not support hotplugging" Reported-by: Vivek Goyal Reviewed-by: Pankaj Gupta Cc: Pankaj Gupta Cc: Igor Mammedov Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4af9679d03..58b1425c17 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1643,13 +1643,13 @@ static void pc_virtio_pmem_pci_pre_plug(HotplugHand= ler *hotplug_dev, HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); Error *local_err =3D NULL; =20 - if (!hotplug_dev2) { + if (!hotplug_dev2 && dev->hotplugged) { /* * Without a bus hotplug handler, we cannot control the plug/unplug - * order. This should never be the case on x86, however better add - * a safety net. + * order. We should never reach this point when hotplugging on x86, + * however, better add a safety net. */ - error_setg(errp, "virtio-pmem-pci not supported on this bus."); + error_setg(errp, "virtio-pmem-pci hotplug not supported on this bu= s."); return; } /* @@ -1658,7 +1658,7 @@ static void pc_virtio_pmem_pci_pre_plug(HotplugHandle= r *hotplug_dev, */ memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL, &local_err); - if (!local_err) { + if (!local_err && hotplug_dev2) { hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err); } error_propagate(errp, local_err); @@ -1676,9 +1676,11 @@ static void pc_virtio_pmem_pci_plug(HotplugHandler *= hotplug_dev, * device bits. */ memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); - hotplug_handler_plug(hotplug_dev2, dev, &local_err); - if (local_err) { - memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); + if (hotplug_dev2) { + hotplug_handler_plug(hotplug_dev2, dev, &local_err); + if (local_err) { + memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); + } } error_propagate(errp, local_err); } --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887685; cv=none; d=zohomail.com; s=zohoarc; b=Ib/+ZKx4j+WRv2e8wb05d1Uy8wBs7TJkBj/Bjdb/tjqKahozTPGE091hKGM6X0SxhYcGmRX7X4apfLq02mSsIqKQFjUVwBfgOmRpjVyzBgcGSsw2uOilWZlYQD5ASWm7oO8eyNg4xrBxXjT3Sp/SRj8+gw6dJvyTiAfmGYbBQT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887685; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6yJ2lEFwsgpUTZUMhX5VCO54V4eVVZ3IAAzP+xX7YP4=; b=jbkGAW8AeZJ+DJEqg9RGcOYuwlk0DVszjI+5n8Abmwuvgvy/big16+TuKwQGiDLmHDZL8lBU/zBlQXz3PsRXWIrvnIdsf2jtaBNRtDW3uABrF6GXQ7rk1ChtxjLgcppjrhGdhhqCxVQbIY2nSFcivlHn0dyBwuy1ZMZ1iP4zPrA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887685986501.2590815738116; Sat, 4 Jul 2020 11:34:45 -0700 (PDT) Received: from localhost ([::1]:47310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmzs-00035f-Mf for importer@patchew.org; Sat, 04 Jul 2020 14:34:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmv3-0002hJ-SK for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37631 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmv0-0001J8-Fz for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:45 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-354--rN_ny73M6CGXQXkuOk72w-1; Sat, 04 Jul 2020 14:29:39 -0400 Received: by mail-wr1-f69.google.com with SMTP id o12so36256124wrj.23 for ; Sat, 04 Jul 2020 11:29:39 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 1sm17150745wmf.0.2020.07.04.11.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6yJ2lEFwsgpUTZUMhX5VCO54V4eVVZ3IAAzP+xX7YP4=; b=hdqT0s1ESB8LOCWz1sfS40AKTwQ4cYDZu1ZwkkbZWsARC0cZqbmcjphgTOX6u7nLMLyoDU L5xneoRaM76GGbyhHxjpBwbIoFrdp27AuHmOsiLkDbssxRXepHa1qk+rAA7H5arh+qHZvn WAO/iFvUTFlhvE9JRwHWIZ9GbZJL3UE= X-MC-Unique: -rN_ny73M6CGXQXkuOk72w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6yJ2lEFwsgpUTZUMhX5VCO54V4eVVZ3IAAzP+xX7YP4=; b=iqJk2SItCcM2GwUPIP688on1koVyZ38Re2z2GgpLXAvXAsnA+hAae9x/4WPB1PIAXD 87hdEBZcogYoycU6SCWqj0BHAW4td/5zavi9SdZOaxGE0fvQRvF8ocBentNZmZ1KE9// P7Ug0tdo7Apb+ky3+SQ3x7Gxi1mH5itn6Pzl0hg+MSUI60gJzGC0F1zJ973DldCXJGRP sKjIvwTuVa/8FE07GQXcf5iciHuS3s9HxFPlIwy/Zs13fgWcHeDNFd/voB+4UW/Dy0+8 r4FggLvJUakRxeFy98Zs7htDYgV70m+de6nCj0WWm4diSFqHSVvOKEXI7FKlONJr86eK R6dw== X-Gm-Message-State: AOAM532ZMKYahpjiDDJLRE7EHJBFRu/spMpn05pgMcGqdMaRA2irfZ9k VcodBR4uJOkLFl43a0fIhH6pvZx83FXZGKiExlrLmmQ5gbceKp2TvdjW4xzX7TYBswjtNXZJfUR FvsKcaOxdy7cuCPY= X-Received: by 2002:a7b:c746:: with SMTP id w6mr44393278wmk.171.1593887378218; Sat, 04 Jul 2020 11:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPsV7s2GgPV3zNqXqrsB08xVzuLtS6iRHigHlJueilVTU2MZ1qgmxHUXcaq5om/YnqA7Ycig== X-Received: by 2002:a7b:c746:: with SMTP id w6mr44393266wmk.171.1593887377987; Sat, 04 Jul 2020 11:29:37 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 05/41] exec: Introduce ram_block_discard_(disable|require)() Message-ID: <20200704182750.1088103-6-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , "Dr . David Alan Gilbert" , Paolo Bonzini , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We want to replace qemu_balloon_inhibit() by something more generic. Especially, we want to make sure that technologies that really rely on RAM block discards to work reliably to run mutual exclusive with technologies that effectively break it. E.g., vfio will usually pin all guest memory, turning the virtio-balloon basically useless and make the VM consume more memory than reported via the balloon. While the balloon is special already (=3D> no guarantees, same behavior possible afer reboots and with huge pages), this will be different, especially, with virtio-mem. Let's implement a way such that we can make both types of technology run mutually exclusive. We'll convert existing balloon inhibitors in successive patches and add some new ones. Add the check to qemu_balloon_is_inhibited() for now. We might want to make virtio-balloon an acutal inhibitor in the future - however, that requires more thought to not break existing setups. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: Richard Henderson Cc: Paolo Bonzini Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-3-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memory.h | 41 ++++++++++++++++++++++++++++++++++ balloon.c | 3 ++- exec.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 7207025bd4..38ec38b9a8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2472,6 +2472,47 @@ static inline MemOp devend_memop(enum device_endian = end) } #endif =20 +/* + * Inhibit technologies that require discarding of pages in RAM blocks, e.= g., + * to manage the actual amount of memory consumed by the VM (then, the mem= ory + * provided by RAM blocks might be bigger than the desired memory consumpt= ion). + * This *must* be set if: + * - Discarding parts of a RAM blocks does not result in the change being + * reflected in the VM and the pages getting freed. + * - All memory in RAM blocks is pinned or duplicated, invaldiating any pr= evious + * discards blindly. + * - Discarding parts of a RAM blocks will result in integrity issues (e.g= ., + * encrypted VMs). + * Technologies that only temporarily pin the current working set of a + * driver are fine, because we don't expect such pages to be discarded + * (esp. based on guest action like balloon inflation). + * + * This is *not* to be used to protect from concurrent discards (esp., + * postcopy). + * + * Returns 0 if successful. Returns -EBUSY if a technology that relies on + * discards to work reliably is active. + */ +int ram_block_discard_disable(bool state); + +/* + * Inhibit technologies that disable discarding of pages in RAM blocks. + * + * Returns 0 if successful. Returns -EBUSY if discards are already set to + * broken. + */ +int ram_block_discard_require(bool state); + +/* + * Test if discarding of memory in ram blocks is disabled. + */ +bool ram_block_discard_is_disabled(void); + +/* + * Test if discarding of memory in ram blocks is required to work reliably. + */ +bool ram_block_discard_is_required(void); + #endif =20 #endif diff --git a/balloon.c b/balloon.c index f104b42961..5fff79523a 100644 --- a/balloon.c +++ b/balloon.c @@ -40,7 +40,8 @@ static int balloon_inhibit_count; =20 bool qemu_balloon_is_inhibited(void) { - return atomic_read(&balloon_inhibit_count) > 0; + return atomic_read(&balloon_inhibit_count) > 0 || + ram_block_discard_is_disabled(); } =20 void qemu_balloon_inhibit(bool state) diff --git a/exec.c b/exec.c index 21926dc9c7..893636176e 100644 --- a/exec.c +++ b/exec.c @@ -4115,4 +4115,56 @@ void mtree_print_dispatch(AddressSpaceDispatch *d, M= emoryRegion *root) } } =20 +/* + * If positive, discarding RAM is disabled. If negative, discarding RAM is + * required to work and cannot be disabled. + */ +static int ram_block_discard_disabled; + +int ram_block_discard_disable(bool state) +{ + int old; + + if (!state) { + atomic_dec(&ram_block_discard_disabled); + return 0; + } + + do { + old =3D atomic_read(&ram_block_discard_disabled); + if (old < 0) { + return -EBUSY; + } + } while (atomic_cmpxchg(&ram_block_discard_disabled, old, old + 1) != =3D old); + return 0; +} + +int ram_block_discard_require(bool state) +{ + int old; + + if (!state) { + atomic_inc(&ram_block_discard_disabled); + return 0; + } + + do { + old =3D atomic_read(&ram_block_discard_disabled); + if (old > 0) { + return -EBUSY; + } + } while (atomic_cmpxchg(&ram_block_discard_disabled, old, old - 1) != =3D old); + return 0; +} + +bool ram_block_discard_is_disabled(void) +{ + return atomic_read(&ram_block_discard_disabled) > 0; +} + +bool ram_block_discard_is_required(void) +{ + return atomic_read(&ram_block_discard_disabled) < 0; +} + #endif --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887820; cv=none; d=zohomail.com; s=zohoarc; b=RuOc/Cm+BRHXmGrt6cV5OJHn5NyJxVzx29GJKTsimzSoMCCVPDTGBOIdBbT5a/Wg6BOcRv1KLo9n5Uhhw1RrQn02oQV9DMJJLPkxmBK57KIhTt1McP+FYBqLAnv3ROauBhZoDvzhJIeewc6f4pz0ga6720hc/Qt/pYYTh1OYN6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887820; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NzAsGQePlosdLQbLXcIzQnsWDyi+eddzAIRrHxLygng=; b=FtOCoq64ZgttJz9Fu15uKOf+dDecRW9EsuXO8lcWb5FzJbkb83OsDOi/GCuZQjCoB8nyq+rpn/E/ZzjIdD9/tRs8wibFCkm9T6e7dKy3ifPDCN+H9o+3LKF1wfNqqVaYodoTpQV9X7TcEeKlC2FLTGhcilCvoZrc+7lGOHlKPyI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887820246612.6935542273262; Sat, 4 Jul 2020 11:37:00 -0700 (PDT) Received: from localhost ([::1]:55776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn22-0007Ei-Jp for importer@patchew.org; Sat, 04 Jul 2020 14:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmv9-0002jD-EI for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30993 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmv5-0001Kf-KW for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:51 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-eXk7hg6MN_eFw9taHLaZig-1; Sat, 04 Jul 2020 14:29:43 -0400 Received: by mail-wm1-f72.google.com with SMTP id b13so38187100wme.9 for ; Sat, 04 Jul 2020 11:29:42 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id j6sm5200083wro.25.2020.07.04.11.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NzAsGQePlosdLQbLXcIzQnsWDyi+eddzAIRrHxLygng=; b=hn83g9zawUBqWjmXz2SGFLJR+8PoFPu+6re30SpBqmv+LU3NfuXDyc1j+4H+X/NSkBQaa2 cc1CkI12hNOyLZ2i1IdA9LUg0lkawXLVCsQ5296/3a5yTj8+xTvQ/49ZxoAet85xxo/5yj ybfv/G+Kg95mMMynEQXdzU9jt/n/P0E= X-MC-Unique: eXk7hg6MN_eFw9taHLaZig-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NzAsGQePlosdLQbLXcIzQnsWDyi+eddzAIRrHxLygng=; b=jSyBYDv4fWhmKaZlRCySH9OylyMb09tXhGCZQ9KL9uwebrjJ+5POaBng5LxMkFv17T ZsbpgML8LpS+nyb/wXshtrSRIS+C6lw9+p6LpTd+4AIJm+3fes6JXlt39yTaPiEoc1ZE XsjFBVTB7FsOCmtaD/b8p1QnO9G6tNJyEXq28otvrLbHRE8/N4viFI40wDTQqm592zvd n8HJFbNOniJrcZCwW86vt8mqDjxFIoDF1VUYf28hz5GC1BFHqSvldo7ZTvnsv4jQ0Djj BUJGXyiiioZntjzRP3WlARAKqV3uLv7FTe2yZOq9zMpMAvWhAEWujJJ7GITPpv36grhA Mt1Q== X-Gm-Message-State: AOAM530LZ/Cfxm6qZs17wBgJJdKVtQrqeqgKFfZLX176j1ZoJwCWyiIg LZc7m2P0sn/KGSoT0WsKZaCJl1ObkhPOuDUeCQo6Z7uhszmXok41rI0wf2f1P/kWQh3n6ilLUJJ IrO1gDAMz/bGmlb0= X-Received: by 2002:a1c:7216:: with SMTP id n22mr36366284wmc.189.1593887381471; Sat, 04 Jul 2020 11:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC+I9bCPIA+3xvvsLkW20vdpcU/D+oD76UZuOPiNxK7gzuuPsWmJf+4Co/MEYV12o3mKAgWA== X-Received: by 2002:a1c:7216:: with SMTP id n22mr36366269wmc.189.1593887381219; Sat, 04 Jul 2020 11:29:41 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 06/41] vfio: Convert to ram_block_discard_disable() Message-ID: <20200704182750.1088103-7-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tony Krowiak , Peter Maydell , Eric Farman , Pierre Morel , David Hildenbrand , qemu-s390x@nongnu.org, Cornelia Huck , Thomas Huth , Halil Pasic , Christian Borntraeger , Alex Williamson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand VFIO is (except devices without a physical IOMMU or some mediated devices) incompatible with discarding of RAM. The kernel will pin basically all VM memory. Let's convert to ram_block_discard_disable(), which can now fail, in contrast to qemu_balloon_inhibit(). Leave "x-balloon-allowed" named as it is for now. Reviewed-by: Tony Krowiak Acked-by: Cornelia Huck Cc: Cornelia Huck Cc: Alex Williamson Cc: Christian Borntraeger Cc: Tony Krowiak Cc: Halil Pasic Cc: Pierre Morel Cc: Eric Farman Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/vfio/vfio-common.h | 4 +-- hw/vfio/ap.c | 8 +++--- hw/vfio/ccw.c | 11 ++++---- hw/vfio/common.c | 53 +++++++++++++++++++---------------- hw/vfio/pci.c | 6 ++-- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index fd564209ac..c78f3ff559 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -108,7 +108,7 @@ typedef struct VFIODevice { bool reset_works; bool needs_reset; bool no_mmap; - bool balloon_allowed; + bool ram_block_discard_allowed; VFIODeviceOps *ops; unsigned int num_irqs; unsigned int num_regions; @@ -128,7 +128,7 @@ typedef struct VFIOGroup { QLIST_HEAD(, VFIODevice) device_list; QLIST_ENTRY(VFIOGroup) next; QLIST_ENTRY(VFIOGroup) container_next; - bool balloon_allowed; + bool ram_block_discard_allowed; } VFIOGroup; =20 typedef struct VFIODMABuf { diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 95564c17ed..b9330a8e6f 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -105,12 +105,12 @@ static void vfio_ap_realize(DeviceState *dev, Error *= *errp) vapdev->vdev.dev =3D dev; =20 /* - * vfio-ap devices operate in a way compatible with - * memory ballooning, as no pages are pinned in the host. + * vfio-ap devices operate in a way compatible with discarding of + * memory in RAM blocks, as no pages are pinned in the host. * This needs to be set before vfio_get_device() for vfio common to - * handle the balloon inhibitor. + * handle ram_block_discard_disable(). */ - vapdev->vdev.balloon_allowed =3D true; + vapdev->vdev.ram_block_discard_allowed =3D true; =20 ret =3D vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp); if (ret) { diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 06e69d7066..ff7f369779 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -574,12 +574,13 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFI= OCCWDevice *vcdev, =20 /* * All vfio-ccw devices are believed to operate in a way compatible wi= th - * memory ballooning, ie. pages pinned in the host are in the current - * working set of the guest driver and therefore never overlap with pa= ges - * available to the guest balloon driver. This needs to be set before - * vfio_get_device() for vfio common to handle the balloon inhibitor. + * discarding of memory in RAM blocks, ie. pages pinned in the host are + * in the current working set of the guest driver and therefore never + * overlap e.g., with pages available to the guest balloon driver. Th= is + * needs to be set before vfio_get_device() for vfio common to handle + * ram_block_discard_disable(). */ - vcdev->vdev.balloon_allowed =3D true; + vcdev->vdev.ram_block_discard_allowed =3D true; =20 if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) { goto out_err; diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 0b3593b3c0..33357140b8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -33,7 +33,6 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/range.h" -#include "sysemu/balloon.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "trace.h" @@ -1215,31 +1214,36 @@ static int vfio_connect_container(VFIOGroup *group,= AddressSpace *as, space =3D vfio_get_address_space(as); =20 /* - * VFIO is currently incompatible with memory ballooning insofar as the + * VFIO is currently incompatible with discarding of RAM insofar as the * madvise to purge (zap) the page from QEMU's address space does not * interact with the memory API and therefore leaves stale virtual to * physical mappings in the IOMMU if the page was previously pinned. = We - * therefore add a balloon inhibit for each group added to a container, + * therefore set discarding broken for each group added to a container, * whether the container is used individually or shared. This provides * us with options to allow devices within a group to opt-in and allow - * ballooning, so long as it is done consistently for a group (for ins= tance + * discarding, so long as it is done consistently for a group (for ins= tance * if the device is an mdev device where it is known that the host ven= dor * driver will never pin pages outside of the working set of the guest - * driver, which would thus not be ballooning candidates). + * driver, which would thus not be discarding candidates). * * The first opportunity to induce pinning occurs here where we attemp= t to * attach the group to existing containers within the AddressSpace. I= f any - * pages are already zapped from the virtual address space, such as fr= om a - * previous ballooning opt-in, new pinning will cause valid mappings t= o be + * pages are already zapped from the virtual address space, such as fr= om + * previous discards, new pinning will cause valid mappings to be * re-established. Likewise, when the overall MemoryListener for a new * container is registered, a replay of mappings within the AddressSpa= ce * will occur, re-establishing any previously zapped pages as well. * - * NB. Balloon inhibiting does not currently block operation of the - * balloon driver or revoke previously pinned pages, it only prevents - * calling madvise to modify the virtual mapping of ballooned pages. + * Especially virtio-balloon is currently only prevented from discardi= ng + * new memory, it will not yet set ram_block_discard_set_required() and + * therefore, neither stops us here or deals with the sudden memory + * consumption of inflated memory. */ - qemu_balloon_inhibit(true); + ret =3D ram_block_discard_disable(true); + if (ret) { + error_setg_errno(errp, -ret, "Cannot set discarding of RAM broken"= ); + return ret; + } =20 QLIST_FOREACH(container, &space->containers, next) { if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { @@ -1405,7 +1409,7 @@ close_fd_exit: close(fd); =20 put_space_exit: - qemu_balloon_inhibit(false); + ram_block_discard_disable(false); vfio_put_address_space(space); =20 return ret; @@ -1526,8 +1530,8 @@ void vfio_put_group(VFIOGroup *group) return; } =20 - if (!group->balloon_allowed) { - qemu_balloon_inhibit(false); + if (!group->ram_block_discard_allowed) { + ram_block_discard_disable(false); } vfio_kvm_device_del_group(group); vfio_disconnect_container(group); @@ -1565,22 +1569,23 @@ int vfio_get_device(VFIOGroup *group, const char *n= ame, } =20 /* - * Clear the balloon inhibitor for this group if the driver knows the - * device operates compatibly with ballooning. Setting must be consis= tent - * per group, but since compatibility is really only possible with mdev - * currently, we expect singleton groups. + * Set discarding of RAM as not broken for this group if the driver kn= ows + * the device operates compatibly with discarding. Setting must be + * consistent per group, but since compatibility is really only possib= le + * with mdev currently, we expect singleton groups. */ - if (vbasedev->balloon_allowed !=3D group->balloon_allowed) { + if (vbasedev->ram_block_discard_allowed !=3D + group->ram_block_discard_allowed) { if (!QLIST_EMPTY(&group->device_list)) { - error_setg(errp, - "Inconsistent device balloon setting within group"); + error_setg(errp, "Inconsistent setting of support for discardi= ng " + "RAM (e.g., balloon) within group"); close(fd); return -1; } =20 - if (!group->balloon_allowed) { - group->balloon_allowed =3D true; - qemu_balloon_inhibit(false); + if (!group->ram_block_discard_allowed) { + group->ram_block_discard_allowed =3D true; + ram_block_discard_disable(false); } } =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 6838bcc4b3..d020ea9f82 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2789,7 +2789,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 /* - * Mediated devices *might* operate compatibly with memory ballooning,= but + * Mediated devices *might* operate compatibly with discarding of RAM,= but * we cannot know for certain, it depends on whether the mdev vendor d= river * stays in sync with the active working set of the guest driver. Pre= vent * the x-balloon-allowed option unless this is minimally an mdev devic= e. @@ -2802,7 +2802,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 trace_vfio_mdev(vdev->vbasedev.name, is_mdev); =20 - if (vdev->vbasedev.balloon_allowed && !is_mdev) { + if (vdev->vbasedev.ram_block_discard_allowed && !is_mdev) { error_setg(errp, "x-balloon-allowed only potentially compatible " "with mdev devices"); vfio_put_group(group); @@ -3156,7 +3156,7 @@ static Property vfio_pci_dev_properties[] =3D { VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT, false), DEFINE_PROP_BOOL("x-no-mmap", VFIOPCIDevice, vbasedev.no_mmap, false), DEFINE_PROP_BOOL("x-balloon-allowed", VFIOPCIDevice, - vbasedev.balloon_allowed, false), + vbasedev.ram_block_discard_allowed, false), DEFINE_PROP_BOOL("x-no-kvm-intx", VFIOPCIDevice, no_kvm_intx, false), DEFINE_PROP_BOOL("x-no-kvm-msi", VFIOPCIDevice, no_kvm_msi, false), DEFINE_PROP_BOOL("x-no-kvm-msix", VFIOPCIDevice, no_kvm_msix, false), --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887959; cv=none; d=zohomail.com; s=zohoarc; b=n4odvOf5vEyjWBIcRNy9QUEpVJXN8yLOpAe2Avbrf28r9nR/TUIpYtOlvY+DITyoxeG2xcPq9kxyV3qI0hTnc2kuS+564w8tfUVEf5hjzSbSLC+ln+p/CYaAbawtPFwxa+VlhHfMk55xM7iwSQlAqsLO8nTkBRLsdTRCSpP2+iQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887959; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+xCzX5pjcy148tNCg3zvK7ruz7b/+qmBTdtfJlorfws=; b=US/1tY5OLwXHX1SGoq4oyDcMe9W0kXuSt0g12uyU53QvunpLL2UjvWlud8Ukt8EOpSTwaIczlfX4CBbT0CBWArRZ36ajPpsAoFQC7+5oTWqqe0ujR32QJDJrW3hIeb8Ox7ccsub9QEIdhyWhn49P/rdDaI9nBP9JtSElMkxcD+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887959348385.64353112311164; Sat, 4 Jul 2020 11:39:19 -0700 (PDT) Received: from localhost ([::1]:36024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn4I-0002po-4D for importer@patchew.org; Sat, 04 Jul 2020 14:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvB-0002jz-J8 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:54 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:27351 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmv9-0001Kq-3g for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:53 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-3bPySYUwMKaRmG9kgSfoKw-1; Sat, 04 Jul 2020 14:29:45 -0400 Received: by mail-wm1-f69.google.com with SMTP id t18so40173030wmj.5 for ; Sat, 04 Jul 2020 11:29:45 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id s203sm8617891wms.32.2020.07.04.11.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+xCzX5pjcy148tNCg3zvK7ruz7b/+qmBTdtfJlorfws=; b=ZR6PEBeaX3eYlW2P3pB2PvvNykjbilmMPabM/8whGM6hNKAfvmxI1POGPB1+fiueLWm/4+ M9ASU2qiDKV8UApAWhC2TBp6T7IwNth0l41rP5+1BR/lKp46zp6diWhNCiq0LZN9lZTgCx uDcUwecOfqS60af44GA+YcLWB+V+cVw= X-MC-Unique: 3bPySYUwMKaRmG9kgSfoKw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+xCzX5pjcy148tNCg3zvK7ruz7b/+qmBTdtfJlorfws=; b=Iy4F+tnw8oCFvaEJm41CFMnpuC8dQdj4Jh5BcFxpCvVWEmcqbwp73qFwr2VBfKZ5S2 BDP6Cr4EGeTUw6YVphRmvUdvT9h6B7hPhKEtG/K1msxpb9jwxG5uUDY2eq9fY/M0gSC5 shHV+D3PK4XUsMSm2bm+q4GXcBh/7nwLIZPuxFP+Qvx3YJm1RPEDi7Z2rwyDeD+WUdUq pRvFT521vgWNlOSlMrZojfBuZPLKGNbwj37vfObMQC7I+S65Hi7wD9PPMoX0h/QY9okY AFPorbnqUjF6vuJw/4l/PuV0qy4c/qjGTUmMUVYieo1SDoBlin44NZXEPSU5T8HdWQyJ NOuw== X-Gm-Message-State: AOAM530462Jvp/ypJho0g/+FqjzAD9FlgFWvxJnCGl2aNUDlVAh8oxGN UG56eBgWZK9GhJlH6o5+c37owHrY0twjDcKyQ3ZHZBY5P8wfmtrgMov+pdbJDPknmJyCmwkXIRM Yq3uLEWQ0xPwSI7A= X-Received: by 2002:a7b:c5c4:: with SMTP id n4mr41024451wmk.67.1593887383900; Sat, 04 Jul 2020 11:29:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyZyhovHtwPT8kE0hmJqiRfbF25fSUFZBtXZC1AiAdPjMmXjWkRVXCdBx0KDBob2c9vz1Gng== X-Received: by 2002:a7b:c5c4:: with SMTP id n4mr41024439wmk.67.1593887383699; Sat, 04 Jul 2020 11:29:43 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 07/41] accel/kvm: Convert to ram_block_discard_disable() Message-ID: <20200704182750.1088103-8-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , "Dr . David Alan Gilbert" , kvm@vger.kernel.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Discarding memory does not work as expected. At the time this is called, we cannot have anyone active that relies on discards to work properly. Reviewed-by: Dr. David Alan Gilbert Cc: Paolo Bonzini Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-5-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- accel/kvm/kvm-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index d54a8701d8..ab36fbfa0c 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -40,7 +40,6 @@ #include "trace.h" #include "hw/irq.h" #include "sysemu/sev.h" -#include "sysemu/balloon.h" #include "qapi/visitor.h" #include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" @@ -2229,7 +2228,8 @@ static int kvm_init(MachineState *ms) =20 s->sync_mmu =3D !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); if (!s->sync_mmu) { - qemu_balloon_inhibit(true); + ret =3D ram_block_discard_disable(true); + assert(!ret); } =20 return 0; --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887634; cv=none; d=zohomail.com; s=zohoarc; b=K2h+JhASLGgzixGWl6D2g+YB63wHJLb/rRyTX6I/YKUmX/Ca4TbolAwj16eLyIWzuFBvjoEeT6CKn8ROf45jBnKcgPCIc2LZ2m18uSg+tCL+XSBXVNK8vvTcKOXiqDqau3YFMMUkaGvRn7bWYzu1wog7jQE05SJ4pBaRKqd1Vzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887634; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6ynQiUfJj9vMi7GVuuET1BQ3U6a6e7jBcQmv7JseED4=; b=CvmwInYI+OLT1/4wX4rOUhG89UlrqdQzRLQMlQr/PUAqvvUQw2I0/z9AJWUTKx/+6oLtbCd1QDuRJ4Dmuv9RNogZ2UoeaxT4JCLSx2XJ5HrzAY1gUnjJVxOB5Cjmlj4Opu/UoBCwPUY2VXQD+tlYpiBDHkRdnP+6JiECjc35BRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887634355318.50991514001055; Sat, 4 Jul 2020 11:33:54 -0700 (PDT) Received: from localhost ([::1]:42292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmz2-0000ry-V4 for importer@patchew.org; Sat, 04 Jul 2020 14:33:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvB-0002jw-Fg for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24345 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmv9-0001Ky-4W for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:53 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-L3g7IEKvNCCCTXinbbrQ-g-1; Sat, 04 Jul 2020 14:29:48 -0400 Received: by mail-wm1-f69.google.com with SMTP id h25so23405252wmb.0 for ; Sat, 04 Jul 2020 11:29:48 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id e4sm17310270wrt.97.2020.07.04.11.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6ynQiUfJj9vMi7GVuuET1BQ3U6a6e7jBcQmv7JseED4=; b=it+IWp4vB7m8o3Fd6Ez2R12rgf8zBn28ObzOD0+IMLVcJmP67Qs7uf5vKWafjIHVUDad9D H3ZB5P4AHG21DmvLtOJ7TU/gEzq2tTQ0g17CAc5Vj7BY6zKhUQRQjYqcHBU7WGEoli+cz1 q3x1VOqCTu0w8Jixc08kJtistOP333w= X-MC-Unique: L3g7IEKvNCCCTXinbbrQ-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6ynQiUfJj9vMi7GVuuET1BQ3U6a6e7jBcQmv7JseED4=; b=H909GIh8/b51CPbIvpwE8I/ZxNorxyeccPyj4LDIjGCQxxEuS5MUKDGMx4MrYMzPVV lRlBiTMPA7Mb12A4/uH5Jpd8DkypZUki6eNkt/AYVxEwdS+OTqxulQhdYk6pFBYjPNwy nub5TPcIlfCWgqZPs9GRltZ4UBbbVdb6zi6yiSi+2J9s9C+eZyhQiqs8lBtEcMC21tzO VbVp8ZSVkAEqyzQuW1O/qSR274tzqzZzrRHe7XJsFx+Yl5AJ4YkYIlSAL0WjZRa5N32n zKIGSLPx4FJ2leO4i5HxvlecGt7FUYkPC4mKAkOY82wRykQIBDNpuKYjd7rXw4uBnAvX Xpyg== X-Gm-Message-State: AOAM531+uUS4YhxyzcdNAaAcm5QZ/KDelsjIFhCr5SZz1mZLQU0yVslJ q9hGtv7ZISb0gE4AtzL8ynWEEy7AQgicGLOO/pQVuZJ61tE65J7zkeJVTWMa0MOP9JbO7jUbUsX rATSnAVQ6XMTQ38s= X-Received: by 2002:a5d:4b44:: with SMTP id w4mr42131137wrs.275.1593887386765; Sat, 04 Jul 2020 11:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWE1YvwHxLR+3QiabWhv24SvHlyQQj/sIBg07ej0B0o0dKvLd0mH1ao7gKBvpzFaOCynl98w== X-Received: by 2002:a5d:4b44:: with SMTP id w4mr42131125wrs.275.1593887386561; Sat, 04 Jul 2020 11:29:46 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 08/41] s390x/pv: Convert to ram_block_discard_disable() Message-ID: <20200704182750.1088103-9-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Janosch Frank , David Hildenbrand , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Discarding RAM does not work as expected with protected VMs. Let's switch to ram_block_discard_disable() for now, as we want to get rid of qemu_balloon_inhibit(). Note that it will currently never fail, but might fail in the future with new technologies (e.g., virtio-mem). Acked-by: Cornelia Huck Cc: Richard Henderson Cc: Cornelia Huck Cc: Halil Pasic Cc: Christian Borntraeger Cc: Janosch Frank Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-6-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/s390-virtio-ccw.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index b111406d56..023fd25f2b 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -43,7 +43,6 @@ #include "hw/qdev-properties.h" #include "hw/s390x/tod.h" #include "sysemu/sysemu.h" -#include "sysemu/balloon.h" #include "hw/s390x/pv.h" #include "migration/blocker.h" =20 @@ -329,7 +328,7 @@ static void s390_machine_unprotect(S390CcwMachineState = *ms) ms->pv =3D false; migrate_del_blocker(pv_mig_blocker); error_free_or_abort(&pv_mig_blocker); - qemu_balloon_inhibit(false); + ram_block_discard_disable(false); } =20 static int s390_machine_protect(S390CcwMachineState *ms) @@ -338,17 +337,22 @@ static int s390_machine_protect(S390CcwMachineState *= ms) int rc; =20 /* - * Ballooning on protected VMs needs support in the guest for - * sharing and unsharing balloon pages. Block ballooning for - * now, until we have a solution to make at least Linux guests - * either support it or fail gracefully. + * Discarding of memory in RAM blocks does not work as expected with + * protected VMs. Sharing and unsharing pages would be required. Disable + * it for now, until until we have a solution to make at least Linux + * guests either support it (e.g., virtio-balloon) or fail gracefully. */ - qemu_balloon_inhibit(true); + rc =3D ram_block_discard_disable(true); + if (rc) { + error_report("protected VMs: cannot disable RAM discard"); + return rc; + } + error_setg(&pv_mig_blocker, "protected VMs are currently not migrateable."); rc =3D migrate_add_blocker(pv_mig_blocker, &local_err); if (rc) { - qemu_balloon_inhibit(false); + ram_block_discard_disable(false); error_report_err(local_err); error_free_or_abort(&pv_mig_blocker); return rc; @@ -357,7 +361,7 @@ static int s390_machine_protect(S390CcwMachineState *ms) /* Create SE VM */ rc =3D s390_pv_vm_enable(); if (rc) { - qemu_balloon_inhibit(false); + ram_block_discard_disable(false); migrate_del_blocker(pv_mig_blocker); error_free_or_abort(&pv_mig_blocker); return rc; --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888124; cv=none; d=zohomail.com; s=zohoarc; b=mULqqrpQymUx/rr1+RMYd1hpbnpiPQysP039Sf4Y6VGFEzRLBFGC3j+bbfRPLi207+/0EaF248q3KO9RhlTt10ThUdww+u0AfVQWp8RHlTUTUa+gn40jEN/A/df+BiyRw2lZ1Zin69mo3Tk0erqBMD/aItEGY5m/TDRe1TV7COY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888124; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zm5yAzYb8Njf/7lXhPa4kHkewLVdbaNS9bfJJo2eVkw=; b=n1YtG+p7OBFxuXRuJxfacVNwGvTzf0qrussz9pnuS/MwktfUJwvp3QN3iyq6kulwWs5kSSfJfSxF2rxPKTeEmLC7Ni8Fg6QOQddTpFsp7yhcPvFy/BwlQwBvMMYeBLfS51GewuFjYZvwdOU7GlBNr2uqXMgjoICeYj1qC5FIqcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888124858632.1258271700303; Sat, 4 Jul 2020 11:42:04 -0700 (PDT) Received: from localhost ([::1]:44612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn6x-0006rT-8h for importer@patchew.org; Sat, 04 Jul 2020 14:42:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvH-0002qe-LS for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:59 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:54413 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvE-0001Li-2g for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:59 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-6PnnhoqqN--y9A0MwQKy8A-1; Sat, 04 Jul 2020 14:29:51 -0400 Received: by mail-wr1-f70.google.com with SMTP id o25so36283134wro.16 for ; Sat, 04 Jul 2020 11:29:51 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id k126sm17561156wmf.3.2020.07.04.11.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zm5yAzYb8Njf/7lXhPa4kHkewLVdbaNS9bfJJo2eVkw=; b=PkzdohkFNB7e6FDivAsHkrQtKhWn5vgVTFFaI49cGauy/LibYxZaKmkaQko/hUk3gGNgFB 6/5N7B2VCWim2fzkYhHuE9rssN/Kd4POeburrJ/z+d7N9WXc3Aot9HoSWYKHYLpeZPa+zS 9VTJbYTD25UjdiLWyqLVkxx7zzAc1oA= X-MC-Unique: 6PnnhoqqN--y9A0MwQKy8A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zm5yAzYb8Njf/7lXhPa4kHkewLVdbaNS9bfJJo2eVkw=; b=dvklGdJEtLq8anZHGStF2PMCSGmkupYZty3U0mRxGnvMjtx05YbrTSmGxACcmlxSOh DZOFYH6nWngfenNGvF/Pq88he9KdOGump0C2eVl7tOQjAZhx7jTnx2f+AlAgSMVDfh4i tKyDdIaMH11CjLKsqng0b1TqIR48CeWdxztxXt8nMzMq00KmC6e+pLN4UC4uMR7Sks3l YI6Ew0DkB3DDsdJNakEle4lmP7GWoHhS+Z42EL0kLmfcRYU2n4WRs7MXfC2UOCkqL1bG D8cdkJXyDFm8RSmXn2b/ymcRswEw18BmvZAUbB2Jweyxmu52M4TLyLl8RmiV0dgfwSvo k81g== X-Gm-Message-State: AOAM5305DbiVF2l4Qt9FjjPpdHEqSnpASlhA1Q5Es07XiRUAwZIO1hi7 +03QUiUV7rnhvxePmoqUWT7q2KMzFpvIhVx59vb3IV3CD3mysdmbdPZ462TEsChsDsnzk2zZ3LA AnJcjy8nzmQzXPT8= X-Received: by 2002:adf:c542:: with SMTP id s2mr14595704wrf.132.1593887389564; Sat, 04 Jul 2020 11:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPUkCORtKWBkbPb/6lzKY9n4UPADzPmD5jdzm4j4bGl4Uqu9HPX/MWRmFRj8tbWrSy7WBCIg== X-Received: by 2002:adf:c542:: with SMTP id s2mr14595689wrf.132.1593887389195; Sat, 04 Jul 2020 11:29:49 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 09/41] virtio-balloon: Rip out qemu_balloon_inhibit() Message-ID: <20200704182750.1088103-10-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Juan Quintela , "Dr . David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The only remaining special case is postcopy. It cannot handle concurrent discards yet, which would result in requesting already sent pages from the source. Special-case it in virtio-balloon instead. Introduce migration_in_incoming_postcopy(), to find out if incoming postcopy is active. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Michael S. Tsirkin Cc: "Michael S. Tsirkin" Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-7-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/migration/misc.h | 2 ++ include/sysemu/balloon.h | 2 -- balloon.c | 18 ------------------ hw/virtio/virtio-balloon.c | 10 ++++++++-- migration/migration.c | 7 +++++++ migration/postcopy-ram.c | 23 ----------------------- 6 files changed, 17 insertions(+), 45 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index d2762257aa..34e7d75713 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -69,6 +69,8 @@ bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); void migration_global_dump(Monitor *mon); +/* True if incomming migration entered POSTCOPY_INCOMING_DISCARD */ +bool migration_in_incoming_postcopy(void); =20 /* migration/block-dirty-bitmap.c */ void dirty_bitmap_mig_init(void); diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h index aea0c44985..20a2defe3a 100644 --- a/include/sysemu/balloon.h +++ b/include/sysemu/balloon.h @@ -23,7 +23,5 @@ typedef void (QEMUBalloonStatus)(void *opaque, BalloonInf= o *info); int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, QEMUBalloonStatus *stat_func, void *opaque); void qemu_remove_balloon_handler(void *opaque); -bool qemu_balloon_is_inhibited(void); -void qemu_balloon_inhibit(bool state); =20 #endif diff --git a/balloon.c b/balloon.c index 5fff79523a..354408c6ea 100644 --- a/balloon.c +++ b/balloon.c @@ -36,24 +36,6 @@ static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonStatus *balloon_stat_fn; static void *balloon_opaque; -static int balloon_inhibit_count; - -bool qemu_balloon_is_inhibited(void) -{ - return atomic_read(&balloon_inhibit_count) > 0 || - ram_block_discard_is_disabled(); -} - -void qemu_balloon_inhibit(bool state) -{ - if (state) { - atomic_inc(&balloon_inhibit_count); - } else { - atomic_dec(&balloon_inhibit_count); - } - - assert(atomic_read(&balloon_inhibit_count) >=3D 0); -} =20 static bool have_balloon(Error **errp) { diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 8a84718490..ae31f0817a 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -63,6 +63,12 @@ static bool virtio_balloon_pbp_matches(PartiallyBalloone= dPage *pbp, return pbp->base_gpa =3D=3D base_gpa; } =20 +static bool virtio_balloon_inhibited(void) +{ + /* Postcopy cannot deal with concurrent discards, so it's special. */ + return ram_block_discard_is_disabled() || migration_in_incoming_postco= py(); +} + static void balloon_inflate_page(VirtIOBalloon *balloon, MemoryRegion *mr, hwaddr mr_offset, PartiallyBalloonedPage *pbp) @@ -336,7 +342,7 @@ static void virtio_balloon_handle_report(VirtIODevice *= vdev, VirtQueue *vq) * accessible by another device or process, or if the guest is * expecting it to retain a non-zero value. */ - if (qemu_balloon_is_inhibited() || dev->poison_val) { + if (virtio_balloon_inhibited() || dev->poison_val) { goto skip_element; } =20 @@ -421,7 +427,7 @@ static void virtio_balloon_handle_output(VirtIODevice *= vdev, VirtQueue *vq) =20 trace_virtio_balloon_handle_output(memory_region_name(section.= mr), pa); - if (!qemu_balloon_is_inhibited()) { + if (!virtio_balloon_inhibited()) { if (vq =3D=3D s->ivq) { balloon_inflate_page(s, section.mr, section.offset_within_region, &pb= p); diff --git a/migration/migration.c b/migration/migration.c index 481a590f72..d365d82209 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1772,6 +1772,13 @@ bool migration_in_postcopy_after_devices(MigrationSt= ate *s) return migration_in_postcopy() && s->postcopy_after_devices; } =20 +bool migration_in_incoming_postcopy(void) +{ + PostcopyState ps =3D postcopy_state_get(); + + return ps >=3D POSTCOPY_INCOMING_DISCARD && ps < POSTCOPY_INCOMING_END; +} + bool migration_is_idle(void) { MigrationState *s =3D current_migration; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a36402722b..b41a9fe2fd 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -27,7 +27,6 @@ #include "qemu/notify.h" #include "qemu/rcu.h" #include "sysemu/sysemu.h" -#include "sysemu/balloon.h" #include "qemu/error-report.h" #include "trace.h" #include "hw/boards.h" @@ -520,20 +519,6 @@ int postcopy_ram_incoming_init(MigrationIncomingState = *mis) return 0; } =20 -/* - * Manage a single vote to the QEMU balloon inhibitor for all postcopy usa= ge, - * last caller wins. - */ -static void postcopy_balloon_inhibit(bool state) -{ - static bool cur_state =3D false; - - if (state !=3D cur_state) { - qemu_balloon_inhibit(state); - cur_state =3D state; - } -} - /* * At the end of a migration where postcopy_ram_incoming_init was called. */ @@ -565,8 +550,6 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) mis->have_fault_thread =3D false; } =20 - postcopy_balloon_inhibit(false); - if (enable_mlock) { if (os_mlock() < 0) { error_report("mlock: %s", strerror(errno)); @@ -1160,12 +1143,6 @@ int postcopy_ram_incoming_setup(MigrationIncomingSta= te *mis) } memset(mis->postcopy_tmp_zero_page, '\0', mis->largest_page_size); =20 - /* - * Ballooning can mark pages as absent while we're postcopying - * that would cause false userfaults. - */ - postcopy_balloon_inhibit(true); - trace_postcopy_ram_enable_notify(); =20 return 0; --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887750; cv=none; d=zohomail.com; s=zohoarc; b=E3Yv3uVgpJCHhSyECzO8df8RFJQJtorl0aVvUOdfbaYaD5wlb1IKTXWaPXEtU8pIEbyd3AzmnIWj6ySpxSQefIyC9sOtr7/Q3IzA4QATVeeJ1CltWnXIMQWMadox8BflwJPAtUC4EsShWQPe+KcO7yqOzR9f4oqV8pffcnVF1kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887750; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rJ+ftu7sRo4+D1GoB2r1H/Xv24+UlICQh28kpGHM9w0=; b=AhDOiOHp3yjaAJRRNkJ44v9S6Fr43bCNCuqMoj7vPCVxkH7keyz6wzoeiZyX0ssHAz8iiha5LdcKKLcHv0NPHDEpR6rhtQMtN++ocu1/YOsTWvOSfpNtlQ2WCZZ4PxF25v3Lnm0+UXtBBjHLoDBW3vfBq+dTbqGztGBBXQdsoKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887750511491.62637769434446; Sat, 4 Jul 2020 11:35:50 -0700 (PDT) Received: from localhost ([::1]:50752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn0v-0004Ub-8d for importer@patchew.org; Sat, 04 Jul 2020 14:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvF-0002mB-Tr for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25722 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvD-0001Le-LF for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:29:57 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-QhwGETBPMHqkzuRtaSVdDQ-1; Sat, 04 Jul 2020 14:29:53 -0400 Received: by mail-wm1-f72.google.com with SMTP id t18so40173223wmj.5 for ; Sat, 04 Jul 2020 11:29:53 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id c11sm16765277wmb.45.2020.07.04.11.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rJ+ftu7sRo4+D1GoB2r1H/Xv24+UlICQh28kpGHM9w0=; b=VJtFnGqmm2IV3Ey1zh3sNKc4LWqsdEXyn2dcusm9zEdZaxvuCPYam60owRVCRTeeXaV98I ZpNV07++G73AhNUbAbC35ns5zT8EkuUfC1ReSnkIqf+JaMPVgltuv7sZGvjNU9W9xZuczv AKSNMIj0DU9xm+4eVzMlXP0US1Cdncw= X-MC-Unique: QhwGETBPMHqkzuRtaSVdDQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rJ+ftu7sRo4+D1GoB2r1H/Xv24+UlICQh28kpGHM9w0=; b=jpHBLJMxPuo6RjUQtWa6U0eU+GLdwqCFSTfVqbEMlaPlsVeOXzLxexzCH110QBcLVT /6GP1d7IXfKuPfY4gb9cUXccqiz1iFkssT50xAFDBAbFlQHAFHElJ1hijfBNE37v03M2 pzV7Q90/W9fr50+o3xXIlri9JrRuJuGjMA8gcpnVwzzhHcweFPp/tv+C2hW5R/+Q2lDG lyrvBHjE4UaUNYVWsWL42YlVJQHk74NJ4mqitdrP/TRsTHHwG2xhAcMaWLkKpuPu+mXz kRW6Jw8U0fMDLS9B0+mfdchOIkWIBnCvgeXmSKxdIhi0ohMNAa42gxlBzoZBcJ62AWqu 3shA== X-Gm-Message-State: AOAM531oTbJ5cF00b3tQ4P7M+Tvsp0qtAOQNbySj8pcr9kOyoNkk4f17 D2JTmGaW7IVp1luxB8OubcEGluNgkGk4Xsq1ig8QXDGKIpk98wZeRz5QPeIzS7rjcYuKsKvWfkl s1I6ckm6px8QWAnw= X-Received: by 2002:a7b:ce97:: with SMTP id q23mr42520261wmj.89.1593887392065; Sat, 04 Jul 2020 11:29:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypgywOX2uW7oB0F+xcHYZ5odIW5/4MTbqD/5w4NaF9NjLbUW8fLrM47A0wWgS7hsnuWLFz/g== X-Received: by 2002:a7b:ce97:: with SMTP id q23mr42520250wmj.89.1593887391917; Sat, 04 Jul 2020 11:29:51 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 10/41] target/i386: sev: Use ram_block_discard_disable() Message-ID: <20200704182750.1088103-11-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , David Hildenbrand , "Dr . David Alan Gilbert" , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand AMD SEV will pin all guest memory, mark discarding of RAM broken. At the time this is called, we cannot have anyone active that relies on discards to work properly - let's still implement error handling. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-8-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- target/i386/sev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index d273174ad3..f100a53231 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -680,6 +680,12 @@ sev_guest_init(const char *id) uint32_t host_cbitpos; struct sev_user_data_status status =3D {}; =20 + ret =3D ram_block_discard_disable(true); + if (ret) { + error_report("%s: cannot disable RAM discard", __func__); + return NULL; + } + sev =3D lookup_sev_guest_info(id); if (!sev) { error_report("%s: '%s' is not a valid '%s' object", @@ -751,6 +757,7 @@ sev_guest_init(const char *id) return sev; err: sev_guest =3D NULL; + ram_block_discard_disable(false); return NULL; } =20 --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887479; cv=none; d=zohomail.com; s=zohoarc; b=KG9eFnDI5Yd+H2E0QI4HZOIP/jIUT4+ggd9qsDsiXFM9PDyoJ6MifroyD7Wr1a4Ml9YKWQdWmw0kR26OnSeke6qTygvIHmNJpp3wYhrorOmT0O85925+sdNSZr5vaU3JR+pyqN5wrsoOqySqq8t+I+w6MFhbht47nZGECnlvx+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887479; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rnwhkibuuryD3VaVsetE4dEaQSFYlxZxsA4QPNf181w=; b=TojbSxo1NS6QYT5bfB3/k0Dn3lm1+bIqccSOjTV2VcGS/64ITVfbn4bvdhMVftDeYu9LxZT5OtguhAbeRLVSg21x4mVyUvDwiG8fTtM7IrHSCA2trmgNJOiI8Eusjer/dPcyIF51JHF0K7XTsnXR3HIEr2EwszO210UG2YqXzIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15938874798061003.4242886381754; Sat, 4 Jul 2020 11:31:19 -0700 (PDT) Received: from localhost ([::1]:59784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmwY-0004sY-D4 for importer@patchew.org; Sat, 04 Jul 2020 14:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvJ-0002ty-9U for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35966 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvH-0001Lz-Fc for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:00 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-bqjU5aL7N4OiD5aHIShOzg-1; Sat, 04 Jul 2020 14:29:56 -0400 Received: by mail-wr1-f71.google.com with SMTP id v3so6664119wrq.10 for ; Sat, 04 Jul 2020 11:29:55 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 1sm16942120wmf.21.2020.07.04.11.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rnwhkibuuryD3VaVsetE4dEaQSFYlxZxsA4QPNf181w=; b=LA3aDlf1JdiUzt/kHAdQklil35gXSvC3Mwzj0aEWEV/jHqc0po35HRCq5+SK3NVjyeEPK5 F9KBsqwd1++WVt6qHWcD4xcAzf0nVoEFCXE54SGTURUgk0SUr8Cqmgk4Ga8QfBXBs/qhnn RwyO101IAD4kDhdCR1GZ3U9T7drQjiM= X-MC-Unique: bqjU5aL7N4OiD5aHIShOzg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rnwhkibuuryD3VaVsetE4dEaQSFYlxZxsA4QPNf181w=; b=UHg4UHeHTa7c+5svaQvOVOQ82RXWhdl4oWQ1tE00FWrBDPrXE+vukCu6AR1H9EsoXZ laxhn+14tdtNx6P3CINBJVpMpbm/bW/iRfV0HT7GQdKMpWsRNbDZATVdQnSPpZQjfhgI t6ftu787tVgjpoGqqsltOtDvM08+EnW0XBGJMaqbfOi4HmDZ1k1+B99hB+7XdXaqSiTR O/TlcuzigW24ZUOQzpcO6wLwoepF/evCHfjSgMxAgATMIwFdLziLst6MYYtJ5c3h+X3d J0RF0i0OQzXqJ0+1QcMs/52HmH4Wa8AMxFRUGBh3zYvwHFAvu7iZlUe4nuFy5J9SsqJm n0zw== X-Gm-Message-State: AOAM530V5d+5+HZJFN1AXdP1+vfiXtYquLGTR578+eR90lkk5BXA6W2e yHSF2NK00jZWKv7h3gCktGmTUyDI2H/sgQ5Hsaw2ymDXLRT+JohU3lIGDEer/4KjWsofSfhxGuH bNgI6RrU2UojwJCo= X-Received: by 2002:adf:f60a:: with SMTP id t10mr33810099wrp.64.1593887394482; Sat, 04 Jul 2020 11:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkm5yQ1qWIomDDGcWAn4+HbF2EUljM6ONyprgX/l9v5ui6ZJIYpxHdFnFzm7gk0vsOvVd3zA== X-Received: by 2002:adf:f60a:: with SMTP id t10mr33810092wrp.64.1593887394338; Sat, 04 Jul 2020 11:29:54 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 11/41] migration/rdma: Use ram_block_discard_disable() Message-ID: <20200704182750.1088103-12-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Juan Quintela , "Dr . David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand RDMA will pin all guest memory (as documented in docs/rdma.txt). We want to disable RAM block discards - however, to keep it simple use ram_block_discard_is_required() instead of inhibiting. Note: It is not sufficient to limit disabling to pin_all. Even when only conditionally pinning 1 MB chunks, as soon as one page within such a chunk was discarded and one page not, the discarded pages will be pinned as well. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-9-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- migration/rdma.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index ec45d33ba3..bbe6f36627 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -29,6 +29,7 @@ #include "qemu/sockets.h" #include "qemu/bitmap.h" #include "qemu/coroutine.h" +#include "exec/memory.h" #include #include #include @@ -4017,8 +4018,14 @@ void rdma_start_incoming_migration(const char *host_= port, Error **errp) Error *local_err =3D NULL; =20 trace_rdma_start_incoming_migration(); - rdma =3D qemu_rdma_data_init(host_port, &local_err); =20 + /* Avoid ram_block_discard_disable(), cannot change during migration. = */ + if (ram_block_discard_is_required()) { + error_setg(errp, "RDMA: cannot disable RAM discard"); + return; + } + + rdma =3D qemu_rdma_data_init(host_port, &local_err); if (rdma =3D=3D NULL) { goto err; } @@ -4067,10 +4074,17 @@ void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp) { MigrationState *s =3D opaque; - RDMAContext *rdma =3D qemu_rdma_data_init(host_port, errp); RDMAContext *rdma_return_path =3D NULL; + RDMAContext *rdma; int ret =3D 0; =20 + /* Avoid ram_block_discard_disable(), cannot change during migration. = */ + if (ram_block_discard_is_required()) { + error_setg(errp, "RDMA: cannot disable RAM discard"); + return; + } + + rdma =3D qemu_rdma_data_init(host_port, errp); if (rdma =3D=3D NULL) { goto err; } --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888210; cv=none; d=zohomail.com; s=zohoarc; b=Sq3rLVpTj8dFUc3A9xWCxmrb75coPdMqjaS7kGUn4wHWgd46kGq5ExuwYatOf8HL7S0eZkmbzo349IeO5Bwjk22fUE7jVCbzL1SQi6dEKpeJk/sIHoJcL1RQguSYo561eKeYcx2JXd4BFYUAaO6aSmPPPG+6z4ikV1lrwkaVz1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888210; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZxzgbY0wTkljt/EIcrPmrPRKcNp5zQS1Y4vQ0bafojw=; b=oKuUL0eNDPcLEd1oQYH0e235YDZFfYqSQbEwZjj1qyOXJMdkq1AP0WiTJm29alUwqpq9FixrQeIIHhws9AhF61QL1tRqZjDMNXU5Z26ClQS8e6bNGO7DYW0SbhJf5S5iMwoHxwApNFeJmqRVT/kkxnx/InHQP4F8onbPo+Ztw+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888210086323.54251705171043; Sat, 4 Jul 2020 11:43:30 -0700 (PDT) Received: from localhost ([::1]:52970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn8K-0001n1-Rv for importer@patchew.org; Sat, 04 Jul 2020 14:43:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvK-0002wW-Sf for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37380 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvI-0001M6-W4 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:02 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-133-0pXu6DSWO76kUYs3vHedng-1; Sat, 04 Jul 2020 14:29:58 -0400 Received: by mail-wr1-f69.google.com with SMTP id b14so36494309wrp.0 for ; Sat, 04 Jul 2020 11:29:58 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id a2sm17532285wrn.68.2020.07.04.11.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZxzgbY0wTkljt/EIcrPmrPRKcNp5zQS1Y4vQ0bafojw=; b=QLDKjJkNIKV1GtS2jMlbBe4km6qzDCqrAKLpDMNtuS8A3MKVkFc8tiOKTegnr3Zd/zTsgU FC1/VjyP0Ht8Ym6qAgCLS/PG06N40W9sZSoG/ZYHX+SCwSglMxA56iA5vpDzRuIlIUF2V5 PWAgsDuT5chCgAuSOps8zeaZ+l1br5Q= X-MC-Unique: 0pXu6DSWO76kUYs3vHedng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZxzgbY0wTkljt/EIcrPmrPRKcNp5zQS1Y4vQ0bafojw=; b=haTQGgtTrXznnfNo1K26F7r6aJxQekncBCzTeKOP/aCdixoUWfnhu0kZdI39TZ+b6Z LiBS/tnkYR0N62gEn4ZA2Yd6Quxat9krlAh+qWpU3+Li+/j7et7R93McqKcsmjWxUDbB mE9jlWytzuxvXXcZkG9OVaQQ8IpWKatxv+nHgjt8yEa3kFN8CLGxsI0JunMEon4l19S4 NZKWIDdGTP9Z2jU4aDWpdyw52kj3oe5JunU0LtXdh7hLHgm87ToSahVB5omxwZDxTyMx 5xdOFcLgD18Wu26+Yn82mNs6+QM4f+K1C8SfkVkueQ05CVN9Lb5yBiVSvPYjwp5mTb8Q nPcQ== X-Gm-Message-State: AOAM5301UODxWwvk5b58BhfCkisJ+9WQZLfCsnlUKANnc7QLDqwMRppA xqz5V5bEQryQBez53w1DRx06T5cpPIVvrxdoJn22bfTNzPtD7ZufTfLx3RmuU6SL5mH++p5A7Tf 52aAWDxTz8ZYshv4= X-Received: by 2002:adf:f751:: with SMTP id z17mr43693998wrp.114.1593887397130; Sat, 04 Jul 2020 11:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ9idcmARJ6gbILciclkshBvt+LYEcAdu/kw0Akmu/Y60568UwC5HJ05xUJAVaI8s583hA1A== X-Received: by 2002:adf:f751:: with SMTP id z17mr43693986wrp.114.1593887396943; Sat, 04 Jul 2020 11:29:56 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/41] migration/colo: Use ram_block_discard_disable() Message-ID: <20200704182750.1088103-13-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lukas Straub , Hailiang Zhang , Juan Quintela , David Hildenbrand , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand COLO will copy all memory in a RAM block, disable discarding of RAM. Reviewed-by: Dr. David Alan Gilbert Tested-by: Lukas Straub Cc: "Michael S. Tsirkin" Cc: Hailiang Zhang Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-10-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/migration/colo.h | 2 +- migration/migration.c | 8 +++++++- migration/savevm.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 1636e6f907..768e1f04c3 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -25,7 +25,7 @@ void migrate_start_colo_process(MigrationState *s); bool migration_in_colo_state(void); =20 /* loadvm */ -void migration_incoming_enable_colo(void); +int migration_incoming_enable_colo(void); void migration_incoming_disable_colo(void); bool migration_incoming_colo_enabled(void); void *colo_process_incoming_thread(void *opaque); diff --git a/migration/migration.c b/migration/migration.c index d365d82209..92e44e021e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -338,12 +338,18 @@ bool migration_incoming_colo_enabled(void) =20 void migration_incoming_disable_colo(void) { + ram_block_discard_disable(false); migration_colo_enabled =3D false; } =20 -void migration_incoming_enable_colo(void) +int migration_incoming_enable_colo(void) { + if (ram_block_discard_disable(true)) { + error_report("COLO: cannot disable RAM discard"); + return -EBUSY; + } migration_colo_enabled =3D true; + return 0; } =20 void migrate_add_address(SocketAddress *address) diff --git a/migration/savevm.c b/migration/savevm.c index b979ea6e7f..6e01724605 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2111,8 +2111,15 @@ static int loadvm_handle_recv_bitmap(MigrationIncomi= ngState *mis, =20 static int loadvm_process_enable_colo(MigrationIncomingState *mis) { - migration_incoming_enable_colo(); - return colo_init_ram_cache(); + int ret =3D migration_incoming_enable_colo(); + + if (!ret) { + ret =3D colo_init_ram_cache(); + if (ret) { + migration_incoming_disable_colo(); + } + } + return ret; } =20 /* --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887612; cv=none; d=zohomail.com; s=zohoarc; b=QYe4UeOcHSJdTyPY0BPW+hQpuxMRoRlhmshQtfxqkKbRvH+YdwqVoxwktxqmE/zRHfZVpRMNzZXgtwErzqBsMHQCX9IWGy0wqWfg4ADD7dDr4shHn2GVDCpmX+tEZvA7xgMOkz2ZMUalTzW5IMYAdpOi3Qni9gHbdMh23uMNUlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887612; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LW1BtQ7XrSxBhmMERoTcBzeZC36GK0hYXGmHXHk2E+4=; b=mBMVcW4+ixk1xpSwOOzt/YURK3O9AQWcI3qjBgOyuFpH00ic8vZx0oQd4RaJbuG40wBz5fT28Un/JgRKRzMhPJAua5r5sx1GTdaIj4BNgEF74OBdN6tjUOvsZOatfFZ0iEKhXwdg6CO2f517DMOJ8L4AF2XSQNVpSoLiVeWC+yo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15938876124319.544131346485983; Sat, 4 Jul 2020 11:33:32 -0700 (PDT) Received: from localhost ([::1]:40106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmyg-0008My-Td for importer@patchew.org; Sat, 04 Jul 2020 14:33:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvR-00037w-1v for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:09 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38135 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvN-0001OZ-3Q for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:08 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-1zE04H3lN0G1OJAIo3AyLg-1; Sat, 04 Jul 2020 14:30:02 -0400 Received: by mail-wm1-f71.google.com with SMTP id h25so23405463wmb.0 for ; Sat, 04 Jul 2020 11:30:01 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 1sm17151596wmf.0.2020.07.04.11.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LW1BtQ7XrSxBhmMERoTcBzeZC36GK0hYXGmHXHk2E+4=; b=adTyMStr+LmThkLD/Sk3aPRv98dVolqHQQT8LHY3FRyv4huHEWNwXdJzKgn0ohg01SIufL xC6u39NfmFwXP2pV5b3WZFSrt80c4KjWWplVuiCnDYJtESAG4tW44k94d576r6hYEO8e3l IY91IJEmnKbEZNW60RqmgSIpEv4U21I= X-MC-Unique: 1zE04H3lN0G1OJAIo3AyLg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LW1BtQ7XrSxBhmMERoTcBzeZC36GK0hYXGmHXHk2E+4=; b=QCUBlvL5UaVl5Xx/19eL4v0nnFey6fjykAmQSXaV/31SEF8dDJFIWjCjzENt946Zx4 p5p3+dLV4jO7N5SPAsb6Izk0B64VG5krwRGqDfXcKGgZT7QanwdJm/any0ZPI18D66tu UgwJLooeBOHAzlWDWnJgi4/0uq/kZwEYICRw4Q8ddyJu3eWVpt0A4FUy3j2UjzGqJYmV czNt9A+gAS6tDb/9RACUP9+/Lhd4JHgZ6cVWvdpKxbMQx1CFX08lnxrpkKfo8hNQz9dt KfZR5OrtvOoGi7KbWbSYhNUDJqSXxla0AZ3VOU7hQlqQ9LzSDewQOex9rgfahpfDariB Yl5g== X-Gm-Message-State: AOAM530RKS7zo50DT/BaDUDtkz2Vpp9BihbIlR/Kp0ixCKVkEGbtOLxj 0s41QBmHogSX5x2UEoEwHVJJMXjOo1L8joqxTfzZqYj0ScvsWlVXrv0JryIlmgPNizzDraKEBbO lJYWPZlL0WhLPTLw= X-Received: by 2002:adf:f889:: with SMTP id u9mr45851953wrp.149.1593887400135; Sat, 04 Jul 2020 11:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzETbRmMT8RspEf1a+sxjHfu0vSln7oA/8QGvVA9E/j9SiSxBTeYSvWlp0CjUK6zKiDg2WEkw== X-Received: by 2002:adf:f889:: with SMTP id u9mr45851941wrp.149.1593887399672; Sat, 04 Jul 2020 11:29:59 -0700 (PDT) Date: Sat, 4 Jul 2020 14:29:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 13/41] virtio-mem: Paravirtualized memory hot(un)plug Message-ID: <20200704182750.1088103-14-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Markus Armbruster , "Dr. David Alan Gilbert" , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand This is the very basic/initial version of virtio-mem. An introduction to virtio-mem can be found in the Linux kernel driver [1]. While it can be used in the current state for hotplug of a smaller amount of memory, it will heavily benefit from resizeable memory regions in the future. Each virtio-mem device manages a memory region (provided via a memory backend). After requested by the hypervisor ("requested-size"), the guest can try to plug/unplug blocks of memory within that region, in order to reach the requested size. Initially, and after a reboot, all memory is unplugged (except in special cases - reboot during postcopy). The guest may only try to plug/unplug blocks of memory within the usable region size. The usable region size is a little bigger than the requested size, to give the device driver some flexibility. The usable region size will only grow, except on reboots or when all memory is requested to get unplugged. The guest can never plug more memory than requested. Unplugged memory will get zapped/discarded, similar to in a balloon device. The block size is variable, however, it is always chosen in a way such that THP splits are avoided (e.g., 2MB). The state of each block (plugged/unplugged) is tracked in a bitmap. As virtio-mem devices (e.g., virtio-mem-pci) will be memory devices, we now expose "VirtioMEMDeviceInfo" via "query-memory-devices". Reviewed-by: Michael S. Tsirkin -------------------------------------------------------------------------- There are two important follow-up items that are in the works: 1. Resizeable memory regions: Use resizeable allocations/RAM blocks to grow/shrink along with the usable region size. This avoids creating initially very big VMAs, RAM blocks, and KVM slots. 2. Protection of unplugged memory: Make sure the gust cannot actually make use of unplugged memory. Other follow-up items that are in the works: 1. Exclude unplugged memory during migration (via precopy notifier). 2. Handle remapping of memory. 3. Support for other architectures. -------------------------------------------------------------------------- Example usage (virtio-mem-pci is introduced in follow-up patches): Start QEMU with two virtio-mem devices (one per NUMA node): $ qemu-system-x86_64 -m 4G,maxmem=3D20G \ -smp sockets=3D2,cores=3D2 \ -numa node,nodeid=3D0,cpus=3D0-1 -numa node,nodeid=3D1,cpus=3D2-3 \ [...] -object memory-backend-ram,id=3Dmem0,size=3D8G \ -device virtio-mem-pci,id=3Dvm0,memdev=3Dmem0,node=3D0,requested-size=3D0= M \ -object memory-backend-ram,id=3Dmem1,size=3D8G \ -device virtio-mem-pci,id=3Dvm1,memdev=3Dmem1,node=3D1,requested-size=3D1G Query the configuration: (qemu) info memory-devices Memory device [virtio-mem]: "vm0" memaddr: 0x140000000 node: 0 requested-size: 0 size: 0 max-size: 8589934592 block-size: 2097152 memdev: /objects/mem0 Memory device [virtio-mem]: "vm1" memaddr: 0x340000000 node: 1 requested-size: 1073741824 size: 1073741824 max-size: 8589934592 block-size: 2097152 memdev: /objects/mem1 Add some memory to node 0: (qemu) qom-set vm0 requested-size 500M Remove some memory from node 1: (qemu) qom-set vm1 requested-size 200M Query the configuration again: (qemu) info memory-devices Memory device [virtio-mem]: "vm0" memaddr: 0x140000000 node: 0 requested-size: 524288000 size: 524288000 max-size: 8589934592 block-size: 2097152 memdev: /objects/mem0 Memory device [virtio-mem]: "vm1" memaddr: 0x340000000 node: 1 requested-size: 209715200 size: 209715200 max-size: 8589934592 block-size: 2097152 memdev: /objects/mem1 [1] https://lkml.kernel.org/r/20200311171422.10484-1-david@redhat.com Cc: "Michael S. Tsirkin" Cc: Eric Blake Cc: Markus Armbruster Cc: "Dr. David Alan Gilbert" Cc: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-11-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/misc.json | 39 +- include/hw/virtio/virtio-mem.h | 78 ++++ hw/virtio/virtio-mem.c | 724 +++++++++++++++++++++++++++++++++ hw/virtio/Kconfig | 11 + hw/virtio/Makefile.objs | 1 + 5 files changed, 852 insertions(+), 1 deletion(-) create mode 100644 include/hw/virtio/virtio-mem.h create mode 100644 hw/virtio/virtio-mem.c diff --git a/qapi/misc.json b/qapi/misc.json index a5a0beb902..65ca3edf32 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1356,19 +1356,56 @@ } } =20 +## +# @VirtioMEMDeviceInfo: +# +# VirtioMEMDevice state information +# +# @id: device's ID +# +# @memaddr: physical address in memory, where device is mapped +# +# @requested-size: the user requested size of the device +# +# @size: the (current) size of memory that the device provides +# +# @max-size: the maximum size of memory that the device can provide +# +# @block-size: the block size of memory that the device provides +# +# @node: NUMA node number where device is assigned to +# +# @memdev: memory backend linked with the region +# +# Since: 5.1 +## +{ 'struct': 'VirtioMEMDeviceInfo', + 'data': { '*id': 'str', + 'memaddr': 'size', + 'requested-size': 'size', + 'size': 'size', + 'max-size': 'size', + 'block-size': 'size', + 'node': 'int', + 'memdev': 'str' + } +} + ## # @MemoryDeviceInfo: # # Union containing information about a memory device # # nvdimm is included since 2.12. virtio-pmem is included since 4.1. +# virtio-mem is included since 5.1. # # Since: 2.1 ## { 'union': 'MemoryDeviceInfo', 'data': { 'dimm': 'PCDIMMDeviceInfo', 'nvdimm': 'PCDIMMDeviceInfo', - 'virtio-pmem': 'VirtioPMEMDeviceInfo' + 'virtio-pmem': 'VirtioPMEMDeviceInfo', + 'virtio-mem': 'VirtioMEMDeviceInfo' } } =20 diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h new file mode 100644 index 0000000000..6981096f7c --- /dev/null +++ b/include/hw/virtio/virtio-mem.h @@ -0,0 +1,78 @@ +/* + * Virtio MEM device + * + * Copyright (C) 2020 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_VIRTIO_MEM_H +#define HW_VIRTIO_MEM_H + +#include "standard-headers/linux/virtio_mem.h" +#include "hw/virtio/virtio.h" +#include "qapi/qapi-types-misc.h" +#include "sysemu/hostmem.h" + +#define TYPE_VIRTIO_MEM "virtio-mem" + +#define VIRTIO_MEM(obj) \ + OBJECT_CHECK(VirtIOMEM, (obj), TYPE_VIRTIO_MEM) +#define VIRTIO_MEM_CLASS(oc) \ + OBJECT_CLASS_CHECK(VirtIOMEMClass, (oc), TYPE_VIRTIO_MEM) +#define VIRTIO_MEM_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VirtIOMEMClass, (obj), TYPE_VIRTIO_MEM) + +#define VIRTIO_MEM_MEMDEV_PROP "memdev" +#define VIRTIO_MEM_NODE_PROP "node" +#define VIRTIO_MEM_SIZE_PROP "size" +#define VIRTIO_MEM_REQUESTED_SIZE_PROP "requested-size" +#define VIRTIO_MEM_BLOCK_SIZE_PROP "block-size" +#define VIRTIO_MEM_ADDR_PROP "memaddr" + +typedef struct VirtIOMEM { + VirtIODevice parent_obj; + + /* guest -> host request queue */ + VirtQueue *vq; + + /* bitmap used to track unplugged memory */ + int32_t bitmap_size; + unsigned long *bitmap; + + /* assigned memory backend and memory region */ + HostMemoryBackend *memdev; + + /* NUMA node */ + uint32_t node; + + /* assigned address of the region in guest physical memory */ + uint64_t addr; + + /* usable region size (<=3D region_size) */ + uint64_t usable_region_size; + + /* actual size (how much the guest plugged) */ + uint64_t size; + + /* requested size */ + uint64_t requested_size; + + /* block size and alignment */ + uint64_t block_size; +} VirtIOMEM; + +typedef struct VirtIOMEMClass { + /* private */ + VirtIODevice parent; + + /* public */ + void (*fill_device_info)(const VirtIOMEM *vmen, VirtioMEMDeviceInfo *v= i); + MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp); +} VirtIOMEMClass; + +#endif diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c new file mode 100644 index 0000000000..2d6f3061a6 --- /dev/null +++ b/hw/virtio/virtio-mem.c @@ -0,0 +1,724 @@ +/* + * Virtio MEM device + * + * Copyright (C) 2020 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/iov.h" +#include "qemu/cutils.h" +#include "qemu/error-report.h" +#include "qemu/units.h" +#include "sysemu/numa.h" +#include "sysemu/sysemu.h" +#include "sysemu/reset.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-access.h" +#include "hw/virtio/virtio-mem.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "exec/ram_addr.h" +#include "migration/misc.h" +#include "hw/boards.h" +#include "hw/qdev-properties.h" +#include "config-devices.h" + +/* + * Use QEMU_VMALLOC_ALIGN, so no THP will have to be split when unplugging + * memory (e.g., 2MB on x86_64). + */ +#define VIRTIO_MEM_MIN_BLOCK_SIZE QEMU_VMALLOC_ALIGN +/* + * Size the usable region bigger than the requested size if possible. Esp. + * Linux guests will only add (aligned) memory blocks in case they fully + * fit into the usable region, but plug+online only a subset of the pages. + * The memory block size corresponds mostly to the section size. + * + * This allows e.g., to add 20MB with a section size of 128MB on x86_64, a= nd + * a section size of 1GB on arm64 (as long as the start address is properly + * aligned, similar to ordinary DIMMs). + * + * We can change this at any time and maybe even make it configurable if + * necessary (as the section size can change). But it's more likely that t= he + * section size will rather get smaller and not bigger over time. + */ +#if defined(TARGET_X86_64) || defined(TARGET_I386) +#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB)) +#else +#error VIRTIO_MEM_USABLE_EXTENT not defined +#endif + +static bool virtio_mem_is_busy(void) +{ + /* + * Postcopy cannot handle concurrent discards and we don't want to mig= rate + * pages on-demand with stale content when plugging new blocks. + */ + return migration_in_incoming_postcopy(); +} + +static bool virtio_mem_test_bitmap(VirtIOMEM *vmem, uint64_t start_gpa, + uint64_t size, bool plugged) +{ + const unsigned long first_bit =3D (start_gpa - vmem->addr) / vmem->blo= ck_size; + const unsigned long last_bit =3D first_bit + (size / vmem->block_size)= - 1; + unsigned long found_bit; + + /* We fake a shorter bitmap to avoid searching too far. */ + if (plugged) { + found_bit =3D find_next_zero_bit(vmem->bitmap, last_bit + 1, first= _bit); + } else { + found_bit =3D find_next_bit(vmem->bitmap, last_bit + 1, first_bit); + } + return found_bit > last_bit; +} + +static void virtio_mem_set_bitmap(VirtIOMEM *vmem, uint64_t start_gpa, + uint64_t size, bool plugged) +{ + const unsigned long bit =3D (start_gpa - vmem->addr) / vmem->block_siz= e; + const unsigned long nbits =3D size / vmem->block_size; + + if (plugged) { + bitmap_set(vmem->bitmap, bit, nbits); + } else { + bitmap_clear(vmem->bitmap, bit, nbits); + } +} + +static void virtio_mem_send_response(VirtIOMEM *vmem, VirtQueueElement *el= em, + struct virtio_mem_resp *resp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(vmem); + VirtQueue *vq =3D vmem->vq; + + iov_from_buf(elem->in_sg, elem->in_num, 0, resp, sizeof(*resp)); + + virtqueue_push(vq, elem, sizeof(*resp)); + virtio_notify(vdev, vq); +} + +static void virtio_mem_send_response_simple(VirtIOMEM *vmem, + VirtQueueElement *elem, + uint16_t type) +{ + struct virtio_mem_resp resp =3D { + .type =3D cpu_to_le16(type), + }; + + virtio_mem_send_response(vmem, elem, &resp); +} + +static bool virtio_mem_valid_range(VirtIOMEM *vmem, uint64_t gpa, uint64_t= size) +{ + if (!QEMU_IS_ALIGNED(gpa, vmem->block_size)) { + return false; + } + if (gpa + size < gpa || !size) { + return false; + } + if (gpa < vmem->addr || gpa >=3D vmem->addr + vmem->usable_region_size= ) { + return false; + } + if (gpa + size > vmem->addr + vmem->usable_region_size) { + return false; + } + return true; +} + +static int virtio_mem_set_block_state(VirtIOMEM *vmem, uint64_t start_gpa, + uint64_t size, bool plug) +{ + const uint64_t offset =3D start_gpa - vmem->addr; + int ret; + + if (virtio_mem_is_busy()) { + return -EBUSY; + } + + if (!plug) { + ret =3D ram_block_discard_range(vmem->memdev->mr.ram_block, offset= , size); + if (ret) { + error_report("Unexpected error discarding RAM: %s", + strerror(-ret)); + return -EBUSY; + } + } + virtio_mem_set_bitmap(vmem, start_gpa, size, plug); + return 0; +} + +static int virtio_mem_state_change_request(VirtIOMEM *vmem, uint64_t gpa, + uint16_t nb_blocks, bool plug) +{ + const uint64_t size =3D nb_blocks * vmem->block_size; + int ret; + + if (!virtio_mem_valid_range(vmem, gpa, size)) { + return VIRTIO_MEM_RESP_ERROR; + } + + if (plug && (vmem->size + size > vmem->requested_size)) { + return VIRTIO_MEM_RESP_NACK; + } + + /* test if really all blocks are in the opposite state */ + if (!virtio_mem_test_bitmap(vmem, gpa, size, !plug)) { + return VIRTIO_MEM_RESP_ERROR; + } + + ret =3D virtio_mem_set_block_state(vmem, gpa, size, plug); + if (ret) { + return VIRTIO_MEM_RESP_BUSY; + } + if (plug) { + vmem->size +=3D size; + } else { + vmem->size -=3D size; + } + return VIRTIO_MEM_RESP_ACK; +} + +static void virtio_mem_plug_request(VirtIOMEM *vmem, VirtQueueElement *ele= m, + struct virtio_mem_req *req) +{ + const uint64_t gpa =3D le64_to_cpu(req->u.plug.addr); + const uint16_t nb_blocks =3D le16_to_cpu(req->u.plug.nb_blocks); + uint16_t type; + + type =3D virtio_mem_state_change_request(vmem, gpa, nb_blocks, true); + virtio_mem_send_response_simple(vmem, elem, type); +} + +static void virtio_mem_unplug_request(VirtIOMEM *vmem, VirtQueueElement *e= lem, + struct virtio_mem_req *req) +{ + const uint64_t gpa =3D le64_to_cpu(req->u.unplug.addr); + const uint16_t nb_blocks =3D le16_to_cpu(req->u.unplug.nb_blocks); + uint16_t type; + + type =3D virtio_mem_state_change_request(vmem, gpa, nb_blocks, false); + virtio_mem_send_response_simple(vmem, elem, type); +} + +static void virtio_mem_resize_usable_region(VirtIOMEM *vmem, + uint64_t requested_size, + bool can_shrink) +{ + uint64_t newsize =3D MIN(memory_region_size(&vmem->memdev->mr), + requested_size + VIRTIO_MEM_USABLE_EXTENT); + + if (!requested_size) { + newsize =3D 0; + } + + if (newsize < vmem->usable_region_size && !can_shrink) { + return; + } + + vmem->usable_region_size =3D newsize; +} + +static int virtio_mem_unplug_all(VirtIOMEM *vmem) +{ + RAMBlock *rb =3D vmem->memdev->mr.ram_block; + int ret; + + if (virtio_mem_is_busy()) { + return -EBUSY; + } + + ret =3D ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb)); + if (ret) { + error_report("Unexpected error discarding RAM: %s", strerror(-ret)= ); + return -EBUSY; + } + bitmap_clear(vmem->bitmap, 0, vmem->bitmap_size); + vmem->size =3D 0; + + virtio_mem_resize_usable_region(vmem, vmem->requested_size, true); + return 0; +} + +static void virtio_mem_unplug_all_request(VirtIOMEM *vmem, + VirtQueueElement *elem) +{ + if (virtio_mem_unplug_all(vmem)) { + virtio_mem_send_response_simple(vmem, elem, VIRTIO_MEM_RESP_BUSY); + } else { + virtio_mem_send_response_simple(vmem, elem, VIRTIO_MEM_RESP_ACK); + } +} + +static void virtio_mem_state_request(VirtIOMEM *vmem, VirtQueueElement *el= em, + struct virtio_mem_req *req) +{ + const uint16_t nb_blocks =3D le16_to_cpu(req->u.state.nb_blocks); + const uint64_t gpa =3D le64_to_cpu(req->u.state.addr); + const uint64_t size =3D nb_blocks * vmem->block_size; + struct virtio_mem_resp resp =3D { + .type =3D cpu_to_le16(VIRTIO_MEM_RESP_ACK), + }; + + if (!virtio_mem_valid_range(vmem, gpa, size)) { + virtio_mem_send_response_simple(vmem, elem, VIRTIO_MEM_RESP_ERROR); + return; + } + + if (virtio_mem_test_bitmap(vmem, gpa, size, true)) { + resp.u.state.state =3D cpu_to_le16(VIRTIO_MEM_STATE_PLUGGED); + } else if (virtio_mem_test_bitmap(vmem, gpa, size, false)) { + resp.u.state.state =3D cpu_to_le16(VIRTIO_MEM_STATE_UNPLUGGED); + } else { + resp.u.state.state =3D cpu_to_le16(VIRTIO_MEM_STATE_MIXED); + } + virtio_mem_send_response(vmem, elem, &resp); +} + +static void virtio_mem_handle_request(VirtIODevice *vdev, VirtQueue *vq) +{ + const int len =3D sizeof(struct virtio_mem_req); + VirtIOMEM *vmem =3D VIRTIO_MEM(vdev); + VirtQueueElement *elem; + struct virtio_mem_req req; + uint16_t type; + + while (true) { + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + return; + } + + if (iov_to_buf(elem->out_sg, elem->out_num, 0, &req, len) < len) { + virtio_error(vdev, "virtio-mem protocol violation: invalid req= uest" + " size: %d", len); + g_free(elem); + return; + } + + if (iov_size(elem->in_sg, elem->in_num) < + sizeof(struct virtio_mem_resp)) { + virtio_error(vdev, "virtio-mem protocol violation: not enough = space" + " for response: %zu", + iov_size(elem->in_sg, elem->in_num)); + g_free(elem); + return; + } + + type =3D le16_to_cpu(req.type); + switch (type) { + case VIRTIO_MEM_REQ_PLUG: + virtio_mem_plug_request(vmem, elem, &req); + break; + case VIRTIO_MEM_REQ_UNPLUG: + virtio_mem_unplug_request(vmem, elem, &req); + break; + case VIRTIO_MEM_REQ_UNPLUG_ALL: + virtio_mem_unplug_all_request(vmem, elem); + break; + case VIRTIO_MEM_REQ_STATE: + virtio_mem_state_request(vmem, elem, &req); + break; + default: + virtio_error(vdev, "virtio-mem protocol violation: unknown req= uest" + " type: %d", type); + g_free(elem); + return; + } + + g_free(elem); + } +} + +static void virtio_mem_get_config(VirtIODevice *vdev, uint8_t *config_data) +{ + VirtIOMEM *vmem =3D VIRTIO_MEM(vdev); + struct virtio_mem_config *config =3D (void *) config_data; + + config->block_size =3D cpu_to_le64(vmem->block_size); + config->node_id =3D cpu_to_le16(vmem->node); + config->requested_size =3D cpu_to_le64(vmem->requested_size); + config->plugged_size =3D cpu_to_le64(vmem->size); + config->addr =3D cpu_to_le64(vmem->addr); + config->region_size =3D cpu_to_le64(memory_region_size(&vmem->memdev->= mr)); + config->usable_region_size =3D cpu_to_le64(vmem->usable_region_size); +} + +static uint64_t virtio_mem_get_features(VirtIODevice *vdev, uint64_t featu= res, + Error **errp) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + + if (ms->numa_state) { +#if defined(CONFIG_ACPI) + virtio_add_feature(&features, VIRTIO_MEM_F_ACPI_PXM); +#endif + } + return features; +} + +static void virtio_mem_system_reset(void *opaque) +{ + VirtIOMEM *vmem =3D VIRTIO_MEM(opaque); + + /* + * During usual resets, we will unplug all memory and shrink the usable + * region size. This is, however, not possible in all scenarios. Then, + * the guest has to deal with this manually (VIRTIO_MEM_REQ_UNPLUG_ALL= ). + */ + virtio_mem_unplug_all(vmem); +} + +static void virtio_mem_device_realize(DeviceState *dev, Error **errp) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + int nb_numa_nodes =3D ms->numa_state ? ms->numa_state->num_nodes : 0; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIOMEM *vmem =3D VIRTIO_MEM(dev); + uint64_t page_size; + RAMBlock *rb; + int ret; + + if (!vmem->memdev) { + error_setg(errp, "'%s' property is not set", VIRTIO_MEM_MEMDEV_PRO= P); + return; + } else if (host_memory_backend_is_mapped(vmem->memdev)) { + char *path =3D object_get_canonical_path_component(OBJECT(vmem->me= mdev)); + + error_setg(errp, "'%s' property specifies a busy memdev: %s", + VIRTIO_MEM_MEMDEV_PROP, path); + g_free(path); + return; + } else if (!memory_region_is_ram(&vmem->memdev->mr) || + memory_region_is_rom(&vmem->memdev->mr) || + !vmem->memdev->mr.ram_block) { + error_setg(errp, "'%s' property specifies an unsupported memdev", + VIRTIO_MEM_MEMDEV_PROP); + return; + } + + if ((nb_numa_nodes && vmem->node >=3D nb_numa_nodes) || + (!nb_numa_nodes && vmem->node)) { + error_setg(errp, "'%s' property has value '%" PRIu32 "', which exc= eeds" + "the number of numa nodes: %d", VIRTIO_MEM_NODE_PROP, + vmem->node, nb_numa_nodes ? nb_numa_nodes : 1); + return; + } + + if (enable_mlock) { + error_setg(errp, "Incompatible with mlock"); + return; + } + + rb =3D vmem->memdev->mr.ram_block; + page_size =3D qemu_ram_pagesize(rb); + + if (vmem->block_size < page_size) { + error_setg(errp, "'%s' property has to be at least the page size (= 0x%" + PRIx64 ")", VIRTIO_MEM_BLOCK_SIZE_PROP, page_size); + return; + } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) { + error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" = PRIx64 + ")", VIRTIO_MEM_REQUESTED_SIZE_PROP, + VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size); + return; + } else if (!QEMU_IS_ALIGNED(memory_region_size(&vmem->memdev->mr), + vmem->block_size)) { + error_setg(errp, "'%s' property memdev size has to be multiples of" + "'%s' (0x%" PRIx64 ")", VIRTIO_MEM_MEMDEV_PROP, + VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size); + return; + } + + if (ram_block_discard_require(true)) { + error_setg(errp, "Discarding RAM is disabled"); + return; + } + + ret =3D ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb)); + if (ret) { + error_setg_errno(errp, -ret, "Unexpected error discarding RAM"); + ram_block_discard_require(false); + return; + } + + virtio_mem_resize_usable_region(vmem, vmem->requested_size, true); + + vmem->bitmap_size =3D memory_region_size(&vmem->memdev->mr) / + vmem->block_size; + vmem->bitmap =3D bitmap_new(vmem->bitmap_size); + + virtio_init(vdev, TYPE_VIRTIO_MEM, VIRTIO_ID_MEM, + sizeof(struct virtio_mem_config)); + vmem->vq =3D virtio_add_queue(vdev, 128, virtio_mem_handle_request); + + host_memory_backend_set_mapped(vmem->memdev, true); + vmstate_register_ram(&vmem->memdev->mr, DEVICE(vmem)); + qemu_register_reset(virtio_mem_system_reset, vmem); +} + +static void virtio_mem_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIOMEM *vmem =3D VIRTIO_MEM(dev); + + qemu_unregister_reset(virtio_mem_system_reset, vmem); + vmstate_unregister_ram(&vmem->memdev->mr, DEVICE(vmem)); + host_memory_backend_set_mapped(vmem->memdev, false); + virtio_del_queue(vdev, 0); + virtio_cleanup(vdev); + g_free(vmem->bitmap); + ram_block_discard_require(false); +} + +static int virtio_mem_restore_unplugged(VirtIOMEM *vmem) +{ + RAMBlock *rb =3D vmem->memdev->mr.ram_block; + unsigned long first_zero_bit, last_zero_bit; + uint64_t offset, length; + int ret; + + /* Find consecutive unplugged blocks and discard the consecutive range= . */ + first_zero_bit =3D find_first_zero_bit(vmem->bitmap, vmem->bitmap_size= ); + while (first_zero_bit < vmem->bitmap_size) { + offset =3D first_zero_bit * vmem->block_size; + last_zero_bit =3D find_next_bit(vmem->bitmap, vmem->bitmap_size, + first_zero_bit + 1) - 1; + length =3D (last_zero_bit - first_zero_bit + 1) * vmem->block_size; + + ret =3D ram_block_discard_range(rb, offset, length); + if (ret) { + error_report("Unexpected error discarding RAM: %s", + strerror(-ret)); + return -EINVAL; + } + first_zero_bit =3D find_next_zero_bit(vmem->bitmap, vmem->bitmap_s= ize, + last_zero_bit + 2); + } + return 0; +} + +static int virtio_mem_post_load(void *opaque, int version_id) +{ + if (migration_in_incoming_postcopy()) { + return 0; + } + + return virtio_mem_restore_unplugged(VIRTIO_MEM(opaque)); +} + +static const VMStateDescription vmstate_virtio_mem_device =3D { + .name =3D "virtio-mem-device", + .minimum_version_id =3D 1, + .version_id =3D 1, + .post_load =3D virtio_mem_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(usable_region_size, VirtIOMEM), + VMSTATE_UINT64(size, VirtIOMEM), + VMSTATE_UINT64(requested_size, VirtIOMEM), + VMSTATE_BITMAP(bitmap, VirtIOMEM, 0, bitmap_size), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_virtio_mem =3D { + .name =3D "virtio-mem", + .minimum_version_id =3D 1, + .version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, +}; + +static void virtio_mem_fill_device_info(const VirtIOMEM *vmem, + VirtioMEMDeviceInfo *vi) +{ + vi->memaddr =3D vmem->addr; + vi->node =3D vmem->node; + vi->requested_size =3D vmem->requested_size; + vi->size =3D vmem->size; + vi->max_size =3D memory_region_size(&vmem->memdev->mr); + vi->block_size =3D vmem->block_size; + vi->memdev =3D object_get_canonical_path(OBJECT(vmem->memdev)); +} + +static MemoryRegion *virtio_mem_get_memory_region(VirtIOMEM *vmem, Error *= *errp) +{ + if (!vmem->memdev) { + error_setg(errp, "'%s' property must be set", VIRTIO_MEM_MEMDEV_PR= OP); + return NULL; + } + + return &vmem->memdev->mr; +} + +static void virtio_mem_get_size(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + const VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + uint64_t value =3D vmem->size; + + visit_type_size(v, name, &value, errp); +} + +static void virtio_mem_get_requested_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + const VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + uint64_t value =3D vmem->requested_size; + + visit_type_size(v, name, &value, errp); +} + +static void virtio_mem_set_requested_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + Error *err =3D NULL; + uint64_t value; + + visit_type_size(v, name, &value, &err); + if (err) { + error_propagate(errp, err); + return; + } + + /* + * The block size and memory backend are not fixed until the device was + * realized. realize() will verify these properties then. + */ + if (DEVICE(obj)->realized) { + if (!QEMU_IS_ALIGNED(value, vmem->block_size)) { + error_setg(errp, "'%s' has to be multiples of '%s' (0x%" PRIx64 + ")", name, VIRTIO_MEM_BLOCK_SIZE_PROP, + vmem->block_size); + return; + } else if (value > memory_region_size(&vmem->memdev->mr)) { + error_setg(errp, "'%s' cannot exceed the memory backend size" + "(0x%" PRIx64 ")", name, + memory_region_size(&vmem->memdev->mr)); + return; + } + + if (value !=3D vmem->requested_size) { + virtio_mem_resize_usable_region(vmem, value, false); + vmem->requested_size =3D value; + } + /* + * Trigger a config update so the guest gets notified. We trigger + * even if the size didn't change (especially helpful for debuggin= g). + */ + virtio_notify_config(VIRTIO_DEVICE(vmem)); + } else { + vmem->requested_size =3D value; + } +} + +static void virtio_mem_get_block_size(Object *obj, Visitor *v, const char = *name, + void *opaque, Error **errp) +{ + const VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + uint64_t value =3D vmem->block_size; + + visit_type_size(v, name, &value, errp); +} + +static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char = *name, + void *opaque, Error **errp) +{ + VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + Error *err =3D NULL; + uint64_t value; + + if (DEVICE(obj)->realized) { + error_setg(errp, "'%s' cannot be changed", name); + return; + } + + visit_type_size(v, name, &value, &err); + if (err) { + error_propagate(errp, err); + return; + } + + if (value < VIRTIO_MEM_MIN_BLOCK_SIZE) { + error_setg(errp, "'%s' property has to be at least 0x%" PRIx32, na= me, + VIRTIO_MEM_MIN_BLOCK_SIZE); + return; + } else if (!is_power_of_2(value)) { + error_setg(errp, "'%s' property has to be a power of two", name); + return; + } + vmem->block_size =3D value; +} + +static void virtio_mem_instance_init(Object *obj) +{ + VirtIOMEM *vmem =3D VIRTIO_MEM(obj); + + vmem->block_size =3D VIRTIO_MEM_MIN_BLOCK_SIZE; + + object_property_add(obj, VIRTIO_MEM_SIZE_PROP, "size", virtio_mem_get_= size, + NULL, NULL, NULL); + object_property_add(obj, VIRTIO_MEM_REQUESTED_SIZE_PROP, "size", + virtio_mem_get_requested_size, + virtio_mem_set_requested_size, NULL, NULL); + object_property_add(obj, VIRTIO_MEM_BLOCK_SIZE_PROP, "size", + virtio_mem_get_block_size, virtio_mem_set_block_si= ze, + NULL, NULL); +} + +static Property virtio_mem_properties[] =3D { + DEFINE_PROP_UINT64(VIRTIO_MEM_ADDR_PROP, VirtIOMEM, addr, 0), + DEFINE_PROP_UINT32(VIRTIO_MEM_NODE_PROP, VirtIOMEM, node, 0), + DEFINE_PROP_LINK(VIRTIO_MEM_MEMDEV_PROP, VirtIOMEM, memdev, + TYPE_MEMORY_BACKEND, HostMemoryBackend *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_mem_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + VirtIOMEMClass *vmc =3D VIRTIO_MEM_CLASS(klass); + + device_class_set_props(dc, virtio_mem_properties); + dc->vmsd =3D &vmstate_virtio_mem; + + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + vdc->realize =3D virtio_mem_device_realize; + vdc->unrealize =3D virtio_mem_device_unrealize; + vdc->get_config =3D virtio_mem_get_config; + vdc->get_features =3D virtio_mem_get_features; + vdc->vmsd =3D &vmstate_virtio_mem_device; + + vmc->fill_device_info =3D virtio_mem_fill_device_info; + vmc->get_memory_region =3D virtio_mem_get_memory_region; +} + +static const TypeInfo virtio_mem_info =3D { + .name =3D TYPE_VIRTIO_MEM, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VirtIOMEM), + .instance_init =3D virtio_mem_instance_init, + .class_init =3D virtio_mem_class_init, + .class_size =3D sizeof(VirtIOMEMClass), +}; + +static void virtio_register_types(void) +{ + type_register_static(&virtio_mem_info); +} + +type_init(virtio_register_types) diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index 83122424fa..0eda25c4e1 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -47,3 +47,14 @@ config VIRTIO_PMEM depends on VIRTIO depends on VIRTIO_PMEM_SUPPORTED select MEM_DEVICE + +config VIRTIO_MEM_SUPPORTED + bool + +config VIRTIO_MEM + bool + default y + depends on VIRTIO + depends on LINUX + depends on VIRTIO_MEM_SUPPORTED + select MEM_DEVICE diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index 13e75f171f..f3a65e01b7 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -19,6 +19,7 @@ obj-$(call land,$(CONFIG_VHOST_USER_FS),$(CONFIG_VIRTIO_P= CI)) +=3D vhost-user-fs-p obj-$(CONFIG_VIRTIO_IOMMU) +=3D virtio-iommu.o obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock-common.o vhost-vsock.o obj-$(CONFIG_VHOST_USER_VSOCK) +=3D vhost-vsock-common.o vhost-user-vsock.o +obj-$(CONFIG_VIRTIO_MEM) +=3D virtio-mem.o =20 ifeq ($(CONFIG_VIRTIO_PCI),y) obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock-pci.o --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887688; cv=none; d=zohomail.com; s=zohoarc; b=ml+pvu02TEZEvHlLA58vw5ujHmmbJLfa1zpugISoYAhj+8KhuzZIyEkGxtdHk2gRgcWzK7KlfsVcSO1JqsTSSmmAs87G7gQvFradTtdPsJYdSS0ezDjYw8NZRjXtorJVdWtlx3BeuRBi37zAXgMqQCAykn8pq92owtK7Up7k9BY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887688; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0fQeQikRy8Q2V3Lt7CmPVpto3iu6bzueyFNbeNFBh7o=; b=dGf0ySgzJTiyfID/nZpsHNTsi5KCaDiECC5aBKJskgtp/iA4XGctvwSCcC3PurynpFtw594nYpCZXAOgJCg3dwrUzOK7aFutjohm5Ia8Kf8mjZP4v1WUb4LYQw83Sus3qCydMtPUxgId7dogQT492XGU/llYCGY1UnZD6k9Yo68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887688229902.1607018271628; Sat, 4 Jul 2020 11:34:48 -0700 (PDT) Received: from localhost ([::1]:47516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrmzu-0003Ah-WE for importer@patchew.org; Sat, 04 Jul 2020 14:34:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvS-0003AQ-89 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21709 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvO-0001Oh-NA for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:09 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-DrLHUaS3P0WgTZFnrYzwDw-1; Sat, 04 Jul 2020 14:30:04 -0400 Received: by mail-wm1-f72.google.com with SMTP id g6so34361647wmk.4 for ; Sat, 04 Jul 2020 11:30:04 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id d2sm18177656wrs.95.2020.07.04.11.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0fQeQikRy8Q2V3Lt7CmPVpto3iu6bzueyFNbeNFBh7o=; b=f0r78Ywrucy5JR9Wz9IIRp4TB9HjZK/fS+xEdWSJvI690MSZkrkfdzWkCOSIvETRAJkn42 qky83JNPOoq1fD8IOwhImZhQdwNaow12BMwmzG8RAVr2JRHqheJwym8TbsKsCgPM9+LbJo nR3cVzin2m6Vr+gxB7U3V+eF49wMD+s= X-MC-Unique: DrLHUaS3P0WgTZFnrYzwDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0fQeQikRy8Q2V3Lt7CmPVpto3iu6bzueyFNbeNFBh7o=; b=Rhg55JdPUrN7uR4z11mIARTfFNKJGKkBFitEdgFS2IQAlgIFlUv/gNMF/PlZIGcYf2 Atvzas/bT54uY1PdATBGSBRES7F8y/syNmHgn0lJ5zZ//9mr2q1+ibFQZn7G8I2YfeKb P0w6Ida37affM4CUamqAaqsZp+IAvqiEs1TDKExVaasTb1/RyCBIRBpNPW8AEXjWZt5Q 4w0z+GiQiTLu4QNO8Nj3IbP9gY4EAj1OWQdHmxeiuBsNKA2s8zpaYYb/7Pupo8Cjpudu yQnqkg95tNqsQlmKC48wAzLfMkqz3dSD3jMSX8OMiLxgKNO8Kb68QTvMG4nMJz8TGJJq MduA== X-Gm-Message-State: AOAM533La/ARqobXWu1Jodh8qCL953GRh4PA74myZ0EyRD86Jwlr74nV P69UaN4mEgFYGZDpxj1GLXLFZU1z0/iy/YcQw6/U4dhlp4L+xBePUvRBMpFv4hX0Z/fBas1ICb0 1GJu2HsMWL+z/OQ8= X-Received: by 2002:adf:b1cf:: with SMTP id r15mr13168585wra.118.1593887402976; Sat, 04 Jul 2020 11:30:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0Ti6I3VvzltQfE1SULhddlz7M2/51SoTIFIO40tkyod0ZJnfKud/GG1oETZf5d6aSUJuS4Q== X-Received: by 2002:adf:b1cf:: with SMTP id r15mr13168571wra.118.1593887402772; Sat, 04 Jul 2020 11:30:02 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 14/41] virtio-pci: Proxy for virtio-mem Message-ID: <20200704182750.1088103-15-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr. David Alan Gilbert" , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's add a proxy for virtio-mem, make it a memory device, and pass-through the properties. Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: "Dr. David Alan Gilbert" Cc: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-12-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem-pci.h | 33 ++++++++++ include/hw/pci/pci.h | 1 + hw/virtio/virtio-mem-pci.c | 129 +++++++++++++++++++++++++++++++++++++ hw/virtio/Makefile.objs | 1 + 4 files changed, 164 insertions(+) create mode 100644 hw/virtio/virtio-mem-pci.h create mode 100644 hw/virtio/virtio-mem-pci.c diff --git a/hw/virtio/virtio-mem-pci.h b/hw/virtio/virtio-mem-pci.h new file mode 100644 index 0000000000..8820cd6628 --- /dev/null +++ b/hw/virtio/virtio-mem-pci.h @@ -0,0 +1,33 @@ +/* + * Virtio MEM PCI device + * + * Copyright (C) 2020 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_VIRTIO_MEM_PCI_H +#define QEMU_VIRTIO_MEM_PCI_H + +#include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-mem.h" + +typedef struct VirtIOMEMPCI VirtIOMEMPCI; + +/* + * virtio-mem-pci: This extends VirtioPCIProxy. + */ +#define TYPE_VIRTIO_MEM_PCI "virtio-mem-pci-base" +#define VIRTIO_MEM_PCI(obj) \ + OBJECT_CHECK(VirtIOMEMPCI, (obj), TYPE_VIRTIO_MEM_PCI) + +struct VirtIOMEMPCI { + VirtIOPCIProxy parent_obj; + VirtIOMEM vdev; +}; + +#endif /* QEMU_VIRTIO_MEM_PCI_H */ diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a4e9c33416..c1bf7d5356 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -87,6 +87,7 @@ extern bool pci_available; #define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012 #define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013 #define PCI_DEVICE_ID_VIRTIO_IOMMU 0x1014 +#define PCI_DEVICE_ID_VIRTIO_MEM 0x1015 =20 #define PCI_VENDOR_ID_REDHAT 0x1b36 #define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001 diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c new file mode 100644 index 0000000000..b325303b32 --- /dev/null +++ b/hw/virtio/virtio-mem-pci.c @@ -0,0 +1,129 @@ +/* + * Virtio MEM PCI device + * + * Copyright (C) 2020 Red Hat, Inc. + * + * Authors: + * David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "virtio-mem-pci.h" +#include "hw/mem/memory-device.h" +#include "qapi/error.h" + +static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VirtIOMEMPCI *mem_pci =3D VIRTIO_MEM_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&mem_pci->vdev); + + qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); + object_property_set_bool(OBJECT(vdev), true, "realized", errp); +} + +static void virtio_mem_pci_set_addr(MemoryDeviceState *md, uint64_t addr, + Error **errp) +{ + object_property_set_uint(OBJECT(md), addr, VIRTIO_MEM_ADDR_PROP, errp); +} + +static uint64_t virtio_mem_pci_get_addr(const MemoryDeviceState *md) +{ + return object_property_get_uint(OBJECT(md), VIRTIO_MEM_ADDR_PROP, + &error_abort); +} + +static MemoryRegion *virtio_mem_pci_get_memory_region(MemoryDeviceState *m= d, + Error **errp) +{ + VirtIOMEMPCI *pci_mem =3D VIRTIO_MEM_PCI(md); + VirtIOMEM *vmem =3D VIRTIO_MEM(&pci_mem->vdev); + VirtIOMEMClass *vmc =3D VIRTIO_MEM_GET_CLASS(vmem); + + return vmc->get_memory_region(vmem, errp); +} + +static uint64_t virtio_mem_pci_get_plugged_size(const MemoryDeviceState *m= d, + Error **errp) +{ + return object_property_get_uint(OBJECT(md), VIRTIO_MEM_SIZE_PROP, + errp); +} + +static void virtio_mem_pci_fill_device_info(const MemoryDeviceState *md, + MemoryDeviceInfo *info) +{ + VirtioMEMDeviceInfo *vi =3D g_new0(VirtioMEMDeviceInfo, 1); + VirtIOMEMPCI *pci_mem =3D VIRTIO_MEM_PCI(md); + VirtIOMEM *vmem =3D VIRTIO_MEM(&pci_mem->vdev); + VirtIOMEMClass *vpc =3D VIRTIO_MEM_GET_CLASS(vmem); + DeviceState *dev =3D DEVICE(md); + + if (dev->id) { + vi->has_id =3D true; + vi->id =3D g_strdup(dev->id); + } + + /* let the real device handle everything else */ + vpc->fill_device_info(vmem, vi); + + info->u.virtio_mem.data =3D vi; + info->type =3D MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM; +} + +static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + MemoryDeviceClass *mdc =3D MEMORY_DEVICE_CLASS(klass); + + k->realize =3D virtio_mem_pci_realize; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D PCI_DEVICE_ID_VIRTIO_MEM; + pcidev_k->revision =3D VIRTIO_PCI_ABI_VERSION; + pcidev_k->class_id =3D PCI_CLASS_OTHERS; + + mdc->get_addr =3D virtio_mem_pci_get_addr; + mdc->set_addr =3D virtio_mem_pci_set_addr; + mdc->get_plugged_size =3D virtio_mem_pci_get_plugged_size; + mdc->get_memory_region =3D virtio_mem_pci_get_memory_region; + mdc->fill_device_info =3D virtio_mem_pci_fill_device_info; +} + +static void virtio_mem_pci_instance_init(Object *obj) +{ + VirtIOMEMPCI *dev =3D VIRTIO_MEM_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_MEM); + object_property_add_alias(obj, VIRTIO_MEM_BLOCK_SIZE_PROP, + OBJECT(&dev->vdev), VIRTIO_MEM_BLOCK_SIZE_PR= OP); + object_property_add_alias(obj, VIRTIO_MEM_SIZE_PROP, OBJECT(&dev->vdev= ), + VIRTIO_MEM_SIZE_PROP); + object_property_add_alias(obj, VIRTIO_MEM_REQUESTED_SIZE_PROP, + OBJECT(&dev->vdev), + VIRTIO_MEM_REQUESTED_SIZE_PROP); +} + +static const VirtioPCIDeviceTypeInfo virtio_mem_pci_info =3D { + .base_name =3D TYPE_VIRTIO_MEM_PCI, + .generic_name =3D "virtio-mem-pci", + .instance_size =3D sizeof(VirtIOMEMPCI), + .instance_init =3D virtio_mem_pci_instance_init, + .class_init =3D virtio_mem_pci_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_MEMORY_DEVICE }, + { } + }, +}; + +static void virtio_mem_pci_register_types(void) +{ + virtio_pci_types_register(&virtio_mem_pci_info); +} +type_init(virtio_mem_pci_register_types) diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index f3a65e01b7..a986708186 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -20,6 +20,7 @@ obj-$(CONFIG_VIRTIO_IOMMU) +=3D virtio-iommu.o obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock-common.o vhost-vsock.o obj-$(CONFIG_VHOST_USER_VSOCK) +=3D vhost-vsock-common.o vhost-user-vsock.o obj-$(CONFIG_VIRTIO_MEM) +=3D virtio-mem.o +common-obj-$(call land,$(CONFIG_VIRTIO_MEM),$(CONFIG_VIRTIO_PCI)) +=3D vir= tio-mem-pci.o =20 ifeq ($(CONFIG_VIRTIO_PCI),y) obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock-pci.o --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887863; cv=none; d=zohomail.com; s=zohoarc; b=OnRP4PMUjnX9afjo81j6Pwi0b7jFjHUw6W7UYqCZs9LkNF0+RiPI4aYA30HfKq310qN4EPXj9J5sjWRcrWuOG8K6DEiEFiKBlD8yPwPdS1lKmKlNrR5uvvzeHZIeE2QckN6YeEGUxQB+WgX96hMrUTpBlqqc1fkK275Jvc3pouM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887863; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P6r2FskKwB1C7cd0JfHkwqOjL7yF8DU7eDQFn/2WuCI=; b=Vo3czk9epNkBEONTH4cVc9duXk3egtlLmTcx5GEucUpiewNs0tn3cHY18y0lwZ5CJj2TrRd/3gBeLTae77tJ6vgV0P7pmyq6DWT3xuWGQgpr6L7th3MmzAV60VM6uwrqqlOADe3+EF1fuXNbn8QI6rQdvlE15ab9Px7g4Ua7jS4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887862995211.74627571718065; Sat, 4 Jul 2020 11:37:42 -0700 (PDT) Received: from localhost ([::1]:59108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn2j-0000kY-QY for importer@patchew.org; Sat, 04 Jul 2020 14:37:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvU-0003Eb-FV for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42668 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvS-0001P3-MX for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:12 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-jciBYOJOMCy7ITHZeCMhoQ-1; Sat, 04 Jul 2020 14:30:06 -0400 Received: by mail-wr1-f72.google.com with SMTP id j16so31064169wrw.3 for ; Sat, 04 Jul 2020 11:30:06 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id b184sm17722440wmc.20.2020.07.04.11.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=P6r2FskKwB1C7cd0JfHkwqOjL7yF8DU7eDQFn/2WuCI=; b=NrwJznvPfI/kXVe8t/K/IMUJNyfZhefArlXyRr3y/5WQT9dW4/3pb36Rf+GAZri+p/7JWx 2Eqq38fUBFtChuDPbJf9JC5ptkKZU9z4JNqRqz+jDe+j1leGcQ8w/nJQnvkL+6Icd67IEX j7x1zz/zE57xu/WiRHZ5jB6RhksnF28= X-MC-Unique: jciBYOJOMCy7ITHZeCMhoQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=P6r2FskKwB1C7cd0JfHkwqOjL7yF8DU7eDQFn/2WuCI=; b=hlz+maUY66BxNp+WvWips5bEW1n5tJ2fS1EgqbbCjQp/RWnJF0dMso0qCmPGQLMeH2 sh8dVHfqnm5Kk0csbHPqEat89BgOORuejtWDltreXaUFRw/yEmamy0/wINHi2199dqTa fCxbLQQKrHBH8oewIDRS8CltWMRvXhgQbiB3gjOHeF41DgqY0vidccRT2xSUiyGskadT yzGweb/1IyrCqMyLHBAr3F9OgONVmeNoZcFulteymz7j+xZhmbxbwh/+MAUPRwWFBVOP ZNSdLms+/XfeOcCH1NDdaYU+ybm47BOKR6x+iUzplHYfdFjwzTEAkeftv8012JVGnhpY QeOA== X-Gm-Message-State: AOAM530v2syI0Qgm4LhxhVYKLn05I7GlDYPDnKhVjqL5dY8WzLp3c0W0 SY7r2jXru66mR3tOll6W8nrhfnZjh+r2QStwdETxn1a9Ji0VmsnsblvyrLxsC5YHR+GmG6VXUBt OA+xoV3GmDu9Zw0I= X-Received: by 2002:a1c:4444:: with SMTP id r65mr40310672wma.129.1593887405609; Sat, 04 Jul 2020 11:30:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziOhc08D/FoT6hHyBL2TK+sGvS3ui80NYHBuOuFxQQikwOOleQieaiGuMLkTR2kG2t+zx4dg== X-Received: by 2002:a1c:4444:: with SMTP id r65mr40310659wma.129.1593887405418; Sat, 04 Jul 2020 11:30:05 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 15/41] MAINTAINERS: Add myself as virtio-mem maintainer Message-ID: <20200704182750.1088103-16-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Alex =?utf-8?Q?Benn=C3=A9e?= , "Dr . David Alan Gilbert" , Markus Armbruster , Aleksandar Markovic , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's make sure patches/bug reports find the right person. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: Peter Maydell Cc: Markus Armbruster Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-13-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index dec252f38b..5f02160436 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1790,6 +1790,15 @@ F: hw/virtio/virtio-crypto.c F: hw/virtio/virtio-crypto-pci.c F: include/hw/virtio/virtio-crypto.h =20 +virtio-mem +M: David Hildenbrand +S: Supported +W: https://virtio-mem.gitlab.io/ +F: hw/virtio/virtio-mem.c +F: hw/virtio/virtio-mem-pci.h +F: hw/virtio/virtio-mem-pci.c +F: include/hw/virtio/virtio-mem.h + nvme M: Keith Busch L: qemu-block@nongnu.org --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888305; cv=none; d=zohomail.com; s=zohoarc; b=LPNE8yl+ucK9Rc9Czu5B4Ln6nlE3lLKLrkyZjM0YyzkBIuq3xnO4ebg8zRbshuO+llNVhSxqD5bKREr9Td7jk3A1fLh1bblPxnB3UlosJe3UrGHMYW6+ob8fr0OqUYYZuaBZVE5gyvAXL4wthEeGe7I+0QWuMRkqjWjwD3fq36Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888305; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iWDsFI9FTPaIYFz+N5tNzGyrP1poUpyqulcQXZoBxbc=; b=J84ILsKe9kCBM09VHR947ypOZ6XQk5Kw57lokdGxS7aKkOukf2yVN7H+IS0wMuSvhVt4HYf9T1VEjKMM+mpH0zB4jZTM2J0mADLPAYYx9eueDsf7pRPbzyhGxkhX3wAVjj69kqWcj/Trd9UEk6BxaoTt22z8TJ3JyW9PxcGKz4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159388830535476.63183775285813; Sat, 4 Jul 2020 11:45:05 -0700 (PDT) Received: from localhost ([::1]:33018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn9s-0005J6-5N for importer@patchew.org; Sat, 04 Jul 2020 14:45:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvW-0003Hu-23 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:14 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48039 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvU-0001PD-3V for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:13 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-o8_5sEFPM9O1kSKFxiwJ8g-1; Sat, 04 Jul 2020 14:30:09 -0400 Received: by mail-wr1-f72.google.com with SMTP id i14so36213788wru.17 for ; Sat, 04 Jul 2020 11:30:09 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id b62sm17081843wmh.38.2020.07.04.11.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iWDsFI9FTPaIYFz+N5tNzGyrP1poUpyqulcQXZoBxbc=; b=LM182bj/piyS/4VhY4DULwKxnC53uaD/3lQOyY60F+7BnfIvHJIwT/GjDRNvhAspVKtR5q l74Yxsj5gcV79JP8T2DZ1HfBabaLzEpkQ4QoxWXO5JA0PPPOFOEw2NET1umIHGK8Lj9BlM JnOwOec6ctbDGrSMb0hedAu2RcZMRZg= X-MC-Unique: o8_5sEFPM9O1kSKFxiwJ8g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iWDsFI9FTPaIYFz+N5tNzGyrP1poUpyqulcQXZoBxbc=; b=WuDF3CKuKRmp1vxDXLfLvctUQvld1nzK4F9ZXBpdvRuEoCUqhpvAOITe39z/BZb2tV 4o/QuXaa2agpvkyZGGxSSIDHv5KqIUUhenEygGLiiVHpOY0uy4e8X2lC5hjDY+bfKzLW Oke1yhj+LMVU20hhz2ruqrs6+MpqBNwTN6gNvfJLDDhScRB7gfOPgtblgCS83jN/g/yP +KQ768q3TXqVBLNn7b+BXLnPJuqrtgtaHbEOsNwOwQOJUu+Hm9eVkLgN4dzWDGZ+1it9 yDo0HDrE+m7mU063/xQZGoJeu/sOxuIedyMhP4hySMqRNrWVJtBNNwOYR/k1nz+pUsyO xozQ== X-Gm-Message-State: AOAM530aM10+7CQTUOvtcrRWuXWsZWZuu9g2YfkzPLZF6dyjZboMOFaM Wo4pQ23+2+BjE+5tNzXukY5zV5rE4gDiKUMdu92DONwC0DIsNXBQ3/ktEDTpIlKFzxtGsXG0GGu SfW32By71bZcxVBg= X-Received: by 2002:a5d:46c7:: with SMTP id g7mr41524255wrs.365.1593887408055; Sat, 04 Jul 2020 11:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwz4D+oj/8FDX+qX2CEY79GF9mGPebi3j3euQoGNIdhFibF9mYEJq1sQN3S8Q2Qdrw/+F18w== X-Received: by 2002:a5d:46c7:: with SMTP id g7mr41524250wrs.365.1593887407851; Sat, 04 Jul 2020 11:30:07 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 16/41] hmp: Handle virtio-mem when printing memory device info Message-ID: <20200704182750.1088103-17-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr . David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Print the memory device info just like for other memory devices. Reviewed-by: Dr. David Alan Gilbert Cc: "Dr. David Alan Gilbert" Cc: "Michael S. Tsirkin" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-14-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- monitor/hmp-cmds.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 2b0b58a336..2ec13e4cc3 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1821,6 +1821,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDic= t *qdict) MemoryDeviceInfoList *info_list =3D qmp_query_memory_devices(&err); MemoryDeviceInfoList *info; VirtioPMEMDeviceInfo *vpi; + VirtioMEMDeviceInfo *vmi; MemoryDeviceInfo *value; PCDIMMDeviceInfo *di; =20 @@ -1855,6 +1856,21 @@ void hmp_info_memory_devices(Monitor *mon, const QDi= ct *qdict) monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size); monitor_printf(mon, " memdev: %s\n", vpi->memdev); break; + case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM: + vmi =3D value->u.virtio_mem.data; + monitor_printf(mon, "Memory device [%s]: \"%s\"\n", + MemoryDeviceInfoKind_str(value->type), + vmi->id ? vmi->id : ""); + monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vmi->mem= addr); + monitor_printf(mon, " node: %" PRId64 "\n", vmi->node); + monitor_printf(mon, " requested-size: %" PRIu64 "\n", + vmi->requested_size); + monitor_printf(mon, " size: %" PRIu64 "\n", vmi->size); + monitor_printf(mon, " max-size: %" PRIu64 "\n", vmi->max_= size); + monitor_printf(mon, " block-size: %" PRIu64 "\n", + vmi->block_size); + monitor_printf(mon, " memdev: %s\n", vmi->memdev); + break; default: g_assert_not_reached(); } --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888003; cv=none; d=zohomail.com; s=zohoarc; b=OMB7AIlm9XT7XP2lb/XN9oKchV8F/lPw/5mxqeKcYY6ifAuxIDOGGVUlIcFsOxJZXydzQw/EZ5nNISdfprI9sPU3V6l8n8dLHwzlaN1iWf3ThzP34N0xc3imt8BQVSqahHnRKZoe6WxEuR0KXjmyGnYi9Vqu3FIMZxJs/Tsur+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888003; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R6v2kcHm1yafmRwNtVM4TnE2cecweMPkWTwUrJuLZnU=; b=BIF5fV/i+CsswOpc5RHltmYfTzGlddp83I9FwtwxU4qBFn/471wyg9Qu/zOD8kDd8jLCwTMEo5aMMIC26G+cxbaLJN9Pp7hcyu1kk4CvtPfiJ4a26hJvyfRmxQS2WxXC56GWdXpUrtngFl2iepYIJFE8zROwd2HaIRy0bL6dMJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159388800309661.46680875207471; Sat, 4 Jul 2020 11:40:03 -0700 (PDT) Received: from localhost ([::1]:39280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn4z-00047b-Rh for importer@patchew.org; Sat, 04 Jul 2020 14:40:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvY-0003Mw-Hw for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53462 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvW-0001Pa-Q1 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:16 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-OJdS_zpbMqiebHdh4qzHeg-1; Sat, 04 Jul 2020 14:30:12 -0400 Received: by mail-wr1-f69.google.com with SMTP id j3so16767105wrq.9 for ; Sat, 04 Jul 2020 11:30:12 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id l132sm17730967wmf.6.2020.07.04.11.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R6v2kcHm1yafmRwNtVM4TnE2cecweMPkWTwUrJuLZnU=; b=BEeQFp6m2Mwhibvc78NDZYkHEfHXdakh3Z2rfyetHCcBAANXukbhs7yRR8qUeY3uea+BM8 df6E/Xg/yqPvWyVLgk1gZoNQCJ9MAyhH8+HO74qwXgww0/0Ax/6i/5T43K9AdegilIGQcm 7DbhcIdmcXcTB7hQ30IaqJnGezm6rEE= X-MC-Unique: OJdS_zpbMqiebHdh4qzHeg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=R6v2kcHm1yafmRwNtVM4TnE2cecweMPkWTwUrJuLZnU=; b=SiMcQldDAESwDbxgy7xFWYk4d5VZh3Eu+X752liQIJUasPTc6yuKkqJhB7GI/PHUeq QHId5I1hwXXtGWehlK6o3XklRWie/wdMc6t4SH35yHFQ+1UfQaf7Tw4GmwFjer6QJ0Iw B7znvX2usGhomMXOLp2b3COlm+31zEOc/RtMQJ1TMNcr5mV6loxYA6es6bZEIctsd/2X qpkoTlNYrlpqGP8MhnhfL7Y/icKcZq5IxxKOovBca5HhTQAb48YlR1rW3C6/Tq1/3IaX otW7bcxQTCAhV8A1FYsdu3KTIp8DZ6x7USa1fxWleABdEFobFC5+pIHwSqVv2JRY9WUr agOg== X-Gm-Message-State: AOAM531pmZjUxmk2Si4kcELhqgZl4zNgdz0Hk8Vhwb1MNGBRhYjhNmgr blkH+56unzwIPSjDQO66gmgFzOPH9QMQ4NrTeJjAeDYkErihRx0eMPwgXYONoiW6ybtGll4uvo7 20JPWh/IS96NR6+s= X-Received: by 2002:a5d:500c:: with SMTP id e12mr40604532wrt.236.1593887410769; Sat, 04 Jul 2020 11:30:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHmxUIKpDcaoq5etE66Urw6aSaFK2lSf8tdCdx3xGXy7ZwJNrI3iXB5APm3ohfbv/mVc/4aw== X-Received: by 2002:a5d:500c:: with SMTP id e12mr40604525wrt.236.1593887410631; Sat, 04 Jul 2020 11:30:10 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/41] numa: Handle virtio-mem in NUMA stats Message-ID: <20200704182750.1088103-18-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , Eduardo Habkost , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Account the memory to the configured nid. Reviewed-by: Pankaj Gupta Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-15-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/core/numa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/core/numa.c b/hw/core/numa.c index 2725886d06..e9aec69afd 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -824,6 +824,7 @@ static void numa_stat_memory_devices(NumaNodeMem node_m= em[]) MemoryDeviceInfoList *info; PCDIMMDeviceInfo *pcdimm_info; VirtioPMEMDeviceInfo *vpi; + VirtioMEMDeviceInfo *vmi; =20 for (info =3D info_list; info; info =3D info->next) { MemoryDeviceInfo *value =3D info->value; @@ -844,6 +845,11 @@ static void numa_stat_memory_devices(NumaNodeMem node_= mem[]) node_mem[0].node_mem +=3D vpi->size; node_mem[0].node_plugged_mem +=3D vpi->size; break; + case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM: + vmi =3D value->u.virtio_mem.data; + node_mem[vmi->node].node_mem +=3D vmi->size; + node_mem[vmi->node].node_plugged_mem +=3D vmi->size; + break; default: g_assert_not_reached(); } --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888409; cv=none; d=zohomail.com; s=zohoarc; b=P/XuU9UtidBiLyXacrdnlfCyqyuZAZg7eJ428TSZvfy4CGifSfepBPdSM232yotdEq6RI5QZJubVKzhr8OlsU7RxHBMkRlt6sBh9eYrxD8xRM98VSdHLmu8komdwF29f3OKNDmmosjADAWmDrz1aiaqocIH/YFwbB+jOm4D9lF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888409; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JOwCv9MKVFDSFgjABrGrn+AVAUp/DMrwQ11TkrNg4cg=; b=BuI/xYr5YM/Lf4vXGYVc5k7aXFpGlhx/k26AIKixNv8nq6AtAk6L+YKU4gFBFE+sBPyxvmKPzFwQkzXQLftPwwpWqLZmOqwwm8GbfdT+xNiVeG79jW/CMYihyD5aPcsbymRL/fjx3V4XLMk6Nz/GUvX09JLilHoy1u1kqhmdPTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888409547672.8479300027487; Sat, 4 Jul 2020 11:46:49 -0700 (PDT) Received: from localhost ([::1]:41484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnBY-0000Lc-8k for importer@patchew.org; Sat, 04 Jul 2020 14:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvb-0003TF-Oo for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:19 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:22672 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvZ-0001Pr-K2 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:19 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-9_pX3sr0PNCzm32s7LzL-Q-1; Sat, 04 Jul 2020 14:30:15 -0400 Received: by mail-wr1-f70.google.com with SMTP id f5so36198623wrv.22 for ; Sat, 04 Jul 2020 11:30:15 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id r3sm19906990wrg.70.2020.07.04.11.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JOwCv9MKVFDSFgjABrGrn+AVAUp/DMrwQ11TkrNg4cg=; b=WXZutLM5+SurtjqGOXINuF+HIaWM0xq4jzhwWNcLDTRatD4VA/v+/SFXNI3+VtDUaNmPWM kuA8hujpJYe6WSZUDUqgWINX9Fh1hyk/37nOcft467v5fh4rwuo2cdUVLI7ojj9wTUFZt+ vV2Uo8yLNYrtGrbI+QTmHWCjWxmtNxY= X-MC-Unique: 9_pX3sr0PNCzm32s7LzL-Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JOwCv9MKVFDSFgjABrGrn+AVAUp/DMrwQ11TkrNg4cg=; b=S+d3s2Ic4k5bltno2y8q9itNNaFZu1Ro6aUyy1ezI8OBrs6hjCnv5Vzfsg4yWh0Asi Sjd5rTNmkzCrQYGzZBIWloaGYK+H7xzbDYq+0l1odtFX9bIAqIlF1b08D5U28DWzJs8+ UDynCtQbDpjE+tPYZJzvmoUJehB3NxbIq6T6BBN4snRc8KDcJCt0sjyTwUo8Yrr3c5pC BRsdVpphrqeCXF4N9sLsZWDrhfKiniY3IprclbG4x4AbeEcfYPSPratwHRO6IfKvIqgn GEWavlUWm0Ms5eziE/vZCpqWM3OGTXQYLpqrgDT6KNxs3d6apyW+TdlLo4OAR51lEP1U vIpA== X-Gm-Message-State: AOAM533tsJdKhpnX8YFmEbM2dhWSc+ag9rkrmc3+Q7QrkLx9Nl4kiTMl TjJW4qsvrE9D72Zys3zdfKTBouD7fyhZ7Jd6DQ2+20GVS1FdDmv436VuZODs8cj7ZQffG/V5dd8 OZl3MhGqZaBSAblw= X-Received: by 2002:adf:f484:: with SMTP id l4mr41375447wro.248.1593887413634; Sat, 04 Jul 2020 11:30:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwJDF3MNrlhs1bobKirRMt/jfcHQZLi6Uli3gnpNXiogqOmeKVhat+xYx4nnqPI5V0A74ehA== X-Received: by 2002:adf:f484:: with SMTP id l4mr41375431wro.248.1593887413403; Sat, 04 Jul 2020 11:30:13 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 18/41] pc: Support for virtio-mem-pci Message-ID: <20200704182750.1088103-19-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Pankaj Gupta , David Hildenbrand , Markus Armbruster , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's wire it up similar to virtio-pmem. Also disallow unplug, so it's harder for users to shoot themselves into the foot. Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Eric Blake Cc: Markus Armbruster Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-16-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 49 ++++++++++++++++++++++++++++--------------------- hw/i386/Kconfig | 1 + 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 58b1425c17..576f2502f9 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -88,6 +88,7 @@ #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h" #include "hw/virtio/virtio-pmem-pci.h" +#include "hw/virtio/virtio-mem-pci.h" #include "hw/mem/memory-device.h" #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" @@ -1637,8 +1638,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, numa_cpu_pre_plug(cpu_slot, dev, errp); } =20 -static void pc_virtio_pmem_pci_pre_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); Error *local_err =3D NULL; @@ -1649,7 +1650,8 @@ static void pc_virtio_pmem_pci_pre_plug(HotplugHandle= r *hotplug_dev, * order. We should never reach this point when hotplugging on x86, * however, better add a safety net. */ - error_setg(errp, "virtio-pmem-pci hotplug not supported on this bu= s."); + error_setg(errp, "hotplug of virtio based memory devices not suppo= rted" + " on this bus."); return; } /* @@ -1664,8 +1666,8 @@ static void pc_virtio_pmem_pci_pre_plug(HotplugHandle= r *hotplug_dev, error_propagate(errp, local_err); } =20 -static void pc_virtio_pmem_pci_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_virtio_md_pci_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandler *hotplug_dev2 =3D qdev_get_bus_hotplug_handler(dev); Error *local_err =3D NULL; @@ -1685,17 +1687,17 @@ static void pc_virtio_pmem_pci_plug(HotplugHandler = *hotplug_dev, error_propagate(errp, local_err); } =20 -static void pc_virtio_pmem_pci_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **er= rp) +static void pc_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { - /* We don't support virtio pmem hot unplug */ - error_setg(errp, "virtio pmem device unplug not supported."); + /* We don't support hot unplug of virtio based memory devices */ + error_setg(errp, "virtio based memory devices cannot be unplugged."); } =20 -static void pc_virtio_pmem_pci_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_virtio_md_pci_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { - /* We don't support virtio pmem hot unplug */ + /* We don't support hot unplug of virtio based memory devices */ } =20 static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, @@ -1705,8 +1707,9 @@ static void pc_machine_device_pre_plug_cb(HotplugHand= ler *hotplug_dev, pc_memory_pre_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_pre_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI)) { - pc_virtio_pmem_pci_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + pc_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); } } =20 @@ -1717,8 +1720,9 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, pc_memory_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_plug(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI)) { - pc_virtio_pmem_pci_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + pc_virtio_md_pci_plug(hotplug_dev, dev, errp); } } =20 @@ -1729,8 +1733,9 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, pc_memory_unplug_request(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_request_cb(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI)) { - pc_virtio_pmem_pci_unplug_request(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + pc_virtio_md_pci_unplug_request(hotplug_dev, dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported de= vice" " type: %s", object_get_typename(OBJECT(dev))); @@ -1744,8 +1749,9 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, pc_memory_unplug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_cb(hotplug_dev, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI)) { - pc_virtio_pmem_pci_unplug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + pc_virtio_md_pci_unplug(hotplug_dev, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -1757,7 +1763,8 @@ static HotplugHandler *pc_get_hotplug_handler(Machine= State *machine, { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_CPU) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI)) { + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { return HOTPLUG_HANDLER(machine); } =20 diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index c93f32f657..03e347b207 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -35,6 +35,7 @@ config PC select ACPI_PCI select ACPI_VMGENID select VIRTIO_PMEM_SUPPORTED + select VIRTIO_MEM_SUPPORTED =20 config PC_PCI bool --=20 MST From nobody Mon Apr 29 06:08:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888154; cv=none; d=zohomail.com; s=zohoarc; b=PN2iIjnm2ameDJQxstgGkgMi3ay99M5TVZmvXKtvg7nnpQDPRQkCPXlUwMO7N1GJ2/UMoWn1CxucfaEpMUzhapYMtJXX3jkzjAG+J9ZOHx9/qQI8LCEXKFePua8/itjqek0w/Ay8rPk3ilr5NLYOnqHrdDxuNXdfw15IPYM9xCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888154; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JdaMdAKWaXVwQnXrCapKxlj+F+s4kQbpEqunmlKdvwE=; b=T1y8WswP3FZAs2A2Wv4s2Qt5AkJ29EFNxN5065RgeHFrXCd63iqMU0rO3KRADZuguDXdBKv0vRSkWczOGPmlPQh4HP2MyQwEnHeeCF5olts6mLfQeKzfYBVGQ1txFEkL9Kee48uDw07yu7qFOD7l7VeruHQT4A5SJYv2MJA028A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888154057337.3250162030412; Sat, 4 Jul 2020 11:42:34 -0700 (PDT) Received: from localhost ([::1]:47688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn7Q-000866-RK for importer@patchew.org; Sat, 04 Jul 2020 14:42:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvd-0003Xz-WC for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33894 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvc-0001Q2-23 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:21 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-cLvnnzVxNdipVIbXh0iSYg-1; Sat, 04 Jul 2020 14:30:17 -0400 Received: by mail-wm1-f72.google.com with SMTP id s134so40197340wme.6 for ; Sat, 04 Jul 2020 11:30:17 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id w7sm17650799wmc.32.2020.07.04.11.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JdaMdAKWaXVwQnXrCapKxlj+F+s4kQbpEqunmlKdvwE=; b=c897AqnkkBu7J0es5XuEoHrv4DtKza6l8fSsk2opqezYCf9H9ifCqy1+zQlmBF9/yMhWXw 6U3haV0MEvO6kZJBMUGVG7eqC+etYieFx+/cvuFJxTlsRZn5Jsv6H++9fk4A3WW6aWhytU Dbe5/8TDab+STAzVCTsQOCM6QCTZQWA= X-MC-Unique: cLvnnzVxNdipVIbXh0iSYg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JdaMdAKWaXVwQnXrCapKxlj+F+s4kQbpEqunmlKdvwE=; b=R5YdSKkVgz1NGw3U5cMs4118nChoXCOOdmtm+bjRxRfG3eMNvF2qTG3Nn6LNCKqSAh ALBqed8W9FrFGtFKrKYNYen1LXKBbV3uURUsG00wz7XBIJ66K2/W4vnjS/NV/kbcRgVV +ZkLH0qOXwNvSAlDOieQAQXmWljgzreqFe6eb/qK+f//MqZfyaykidk3u3M7x2ID9KL4 IBnXtrX7qUyjBbqv2TJU7cNepsX9bJxYXDD7EbC1IYt4TYiTmhr6ZWTSOcvG/xsMIPGB v6du1YGvHm1oAw1K35J+ucnpkEvhZ5ieELXTJ2pOR0dqKu0IsWx4kSwdGGdZCpMKo+1H +p1g== X-Gm-Message-State: AOAM530y9nX5nNzOWmo8BNqVbWN8cP4dNqEo2YHXutY5uBFqRp92gM7G g+yHuJIr/8+87U/e2pfvQLSM1Jpk/pf4Y4TL/Q0TciHErclrY2CGpfyaE1Ff7eWZNQ7SSlHh4Ip C4WCOUmV+8vv+qr8= X-Received: by 2002:a7b:c259:: with SMTP id b25mr18089632wmj.107.1593887416006; Sat, 04 Jul 2020 11:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp+AsqAN3ks7zNIrbl4hjzSPLuk2qff88G5FoEp21b3KjAbxZKD6f2OEsLftfzP49ksq9bug== X-Received: by 2002:a7b:c259:: with SMTP id b25mr18089616wmj.107.1593887415832; Sat, 04 Jul 2020 11:30:15 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 19/41] virtio-mem: Allow notifiers for size changes Message-ID: <20200704182750.1088103-20-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , "Dr . David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We want to send qapi events in case the size of a virtio-mem device changes. This allows upper layers to always know how much memory is actually currently consumed via a virtio-mem device. Unfortuantely, we have to report the id of our proxy device. Let's provide an easy way for our proxy device to register, so it can send the qapi events. Piggy-backing on the notifier infrastructure (although we'll only ever have one notifier registered) seems to be an easy way. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: "Dr. David Alan Gilbert" Cc: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-17-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-mem.h | 5 +++++ hw/virtio/virtio-mem.c | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h index 6981096f7c..b74c77cd42 100644 --- a/include/hw/virtio/virtio-mem.h +++ b/include/hw/virtio/virtio-mem.h @@ -64,6 +64,9 @@ typedef struct VirtIOMEM { =20 /* block size and alignment */ uint64_t block_size; + + /* notifiers to notify when "size" changes */ + NotifierList size_change_notifiers; } VirtIOMEM; =20 typedef struct VirtIOMEMClass { @@ -73,6 +76,8 @@ typedef struct VirtIOMEMClass { /* public */ void (*fill_device_info)(const VirtIOMEM *vmen, VirtioMEMDeviceInfo *v= i); MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp); + void (*add_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier); + void (*remove_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifie= r); } VirtIOMEMClass; =20 #endif diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 2d6f3061a6..6b5551515d 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -184,6 +184,7 @@ static int virtio_mem_state_change_request(VirtIOMEM *v= mem, uint64_t gpa, } else { vmem->size -=3D size; } + notifier_list_notify(&vmem->size_change_notifiers, &vmem->size); return VIRTIO_MEM_RESP_ACK; } =20 @@ -242,7 +243,10 @@ static int virtio_mem_unplug_all(VirtIOMEM *vmem) return -EBUSY; } bitmap_clear(vmem->bitmap, 0, vmem->bitmap_size); - vmem->size =3D 0; + if (vmem->size) { + vmem->size =3D 0; + notifier_list_notify(&vmem->size_change_notifiers, &vmem->size); + } =20 virtio_mem_resize_usable_region(vmem, vmem->requested_size, true); return 0; @@ -561,6 +565,18 @@ static MemoryRegion *virtio_mem_get_memory_region(Virt= IOMEM *vmem, Error **errp) return &vmem->memdev->mr; } =20 +static void virtio_mem_add_size_change_notifier(VirtIOMEM *vmem, + Notifier *notifier) +{ + notifier_list_add(&vmem->size_change_notifiers, notifier); +} + +static void virtio_mem_remove_size_change_notifier(VirtIOMEM *vmem, + Notifier *notifier) +{ + notifier_remove(notifier); +} + static void virtio_mem_get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -668,6 +684,7 @@ static void virtio_mem_instance_init(Object *obj) VirtIOMEM *vmem =3D VIRTIO_MEM(obj); =20 vmem->block_size =3D VIRTIO_MEM_MIN_BLOCK_SIZE; + notifier_list_init(&vmem->size_change_notifiers); =20 object_property_add(obj, VIRTIO_MEM_SIZE_PROP, "size", virtio_mem_get_= size, NULL, NULL, NULL); @@ -705,6 +722,8 @@ static void virtio_mem_class_init(ObjectClass *klass, v= oid *data) =20 vmc->fill_device_info =3D virtio_mem_fill_device_info; vmc->get_memory_region =3D virtio_mem_get_memory_region; + vmc->add_size_change_notifier =3D virtio_mem_add_size_change_notifier; + vmc->remove_size_change_notifier =3D virtio_mem_remove_size_change_not= ifier; } =20 static const TypeInfo virtio_mem_info =3D { --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887821; cv=none; d=zohomail.com; s=zohoarc; b=ClPf7NdYLD0Ft+DnZ3pF8xRXhuM/9LhOySx4kDF8FfYDzfl9rZkQo1DEFRqoQxXHdq9QAbCd9ZdBKQs2N09QZEoFoRi/gJCQfi2XJBYS373QaMvLeBB9A69WWauozeF9gehf3hog2hXAq5Xco3ah2qrPslP7Jd+k8sWAo/yMcaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887821; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=63AWt5cO2CoZEQSqdOKoxy7llPnRyvRbfqBM0GohP60=; b=hozL+pc0rck1z/YDsSKSEqtpjCY5+UrmdTcUIzNu18brQIHpsZKosSRvpB6Y+8z+XNSos4+4FrNubPXnbGQAxEORsl9Cb9haL0QgV41U388kj3qcXw9lAHmGqkuwQU5K+YAt5Al+nO1rDvDMlZd4JuxIXgAawN8Vv9I3pqnlQdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887821808177.40277579643612; Sat, 4 Jul 2020 11:37:01 -0700 (PDT) Received: from localhost ([::1]:56076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn24-0007Ru-9W for importer@patchew.org; Sat, 04 Jul 2020 14:37:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvh-0003fN-6I for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:25 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:38320 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvf-0001QE-8H for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:24 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-ul3c-U9pNtSquUySKOgMFw-1; Sat, 04 Jul 2020 14:30:21 -0400 Received: by mail-wr1-f72.google.com with SMTP id z1so6561565wrn.18 for ; Sat, 04 Jul 2020 11:30:20 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id a22sm16368577wmb.4.2020.07.04.11.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=63AWt5cO2CoZEQSqdOKoxy7llPnRyvRbfqBM0GohP60=; b=ItPdKa90mVbw5N41yk95qykJkFh/T7C7AHf/KtV2UFHUelbupeliPPCGg6rFzmDwKYGyzf f9G9+e3YEBKq3xxImG6bOdQTk8tNdiKeiPeB1xD+CMXxTaumc1oqfIi1cXye/1pHt57uUH wM5RcdJ5PHSv8SfX5CT+xqM8Zz4g5cs= X-MC-Unique: ul3c-U9pNtSquUySKOgMFw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=63AWt5cO2CoZEQSqdOKoxy7llPnRyvRbfqBM0GohP60=; b=O1SXsXF5V4OSWvkolDznauFPh2IhQYS0NpOy55eCfMgvIQjMqlOYw09aKe+EwocbzI HBvR8ptxRQq4mWvTq36q7o9HU7foGnEbmiAp4gu1DGB/NOZHsyQ77beh0ph+F52QiI1D Ax2MQMwFyRe3MFRArHJSENWlb5pAMY4LvnnJmnHfZmq1art25XsD8S9HDWoZM633XwmD ZgxMhhrlFDmV3hoJMPqsJIkQeX7L/IvhxIhBPOxsmmUT1ebkvUMwcoyQdDiaRtVq42Hm Pr+OIWnI9uSoio3ruVL4n7BjQ19p79h3VSd3W2tOUL+MFYx6CndH9VhOxW5Wy4wUAfOu 8JcQ== X-Gm-Message-State: AOAM530IqEa21BHzHhmmlO5fnufM+kS9/7waNEzlfoRx5CszXCVACIAW 8Soqv5ZiLyU3noyxCfiUKy1yQPPwWxJdkcRkg9Ukvo93/9q0nk4qiUyFKyOctyvY6azEFUN53+u 43YtXDLWdtaUfXuQ= X-Received: by 2002:a7b:ca4c:: with SMTP id m12mr42380732wml.33.1593887419422; Sat, 04 Jul 2020 11:30:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc33upr7FFo5w/72akmzREr4WnoMR/JUYuEC2b+6uQVh+92CED8DAXUjDhERo1t5XzAIkb1Q== X-Received: by 2002:a7b:ca4c:: with SMTP id m12mr42380716wml.33.1593887419229; Sat, 04 Jul 2020 11:30:19 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/41] virtio-pci: Send qapi events when the virtio-mem size changes Message-ID: <20200704182750.1088103-21-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Markus Armbruster , "Dr. David Alan Gilbert" , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's register the notifier and trigger the qapi event with the right device id. MEMORY_DEVICE_SIZE_CHANGE is similar to BALLOON_CHANGE, however on a memory device level. Don't unregister the notifier (we neither have finalize() nor unrealize() for VirtIOPCIProxy, so it's not that simple to do it) - both devices are expected to vanish at the same time. Cc: "Michael S. Tsirkin" Cc: Markus Armbruster Cc: "Dr. David Alan Gilbert" Cc: Eric Blake Cc: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-18-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/misc.json | 25 +++++++++++++++++++++++++ hw/virtio/virtio-mem-pci.h | 1 + hw/virtio/virtio-mem-pci.c | 28 ++++++++++++++++++++++++++++ monitor/monitor.c | 1 + 4 files changed, 55 insertions(+) diff --git a/qapi/misc.json b/qapi/misc.json index 65ca3edf32..149c925246 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1434,6 +1434,31 @@ ## { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } =20 +## +# @MEMORY_DEVICE_SIZE_CHANGE: +# +# Emitted when the size of a memory device changes. Only emitted for memory +# devices that can actually change the size (e.g., virtio-mem due to guest +# action). +# +# @id: device's ID +# @size: the new size of memory that the device provides +# +# Note: this event is rate-limited. +# +# Since: 5.1 +# +# Example: +# +# <- { "event": "MEMORY_DEVICE_SIZE_CHANGE", +# "data": { "id": "vm0", "size": 1073741824}, +# "timestamp": { "seconds": 1588168529, "microseconds": 201316 } } +# +## +{ 'event': 'MEMORY_DEVICE_SIZE_CHANGE', + 'data': { '*id': 'str', 'size': 'size' } } + + ## # @MEM_UNPLUG_ERROR: # diff --git a/hw/virtio/virtio-mem-pci.h b/hw/virtio/virtio-mem-pci.h index 8820cd6628..b51a28b275 100644 --- a/hw/virtio/virtio-mem-pci.h +++ b/hw/virtio/virtio-mem-pci.h @@ -28,6 +28,7 @@ typedef struct VirtIOMEMPCI VirtIOMEMPCI; struct VirtIOMEMPCI { VirtIOPCIProxy parent_obj; VirtIOMEM vdev; + Notifier size_change_notifier; }; =20 #endif /* QEMU_VIRTIO_MEM_PCI_H */ diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index b325303b32..1a8e854123 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -14,6 +14,7 @@ #include "virtio-mem-pci.h" #include "hw/mem/memory-device.h" #include "qapi/error.h" +#include "qapi/qapi-events-misc.h" =20 static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) { @@ -74,6 +75,21 @@ static void virtio_mem_pci_fill_device_info(const Memory= DeviceState *md, info->type =3D MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM; } =20 +static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *da= ta) +{ + VirtIOMEMPCI *pci_mem =3D container_of(notifier, VirtIOMEMPCI, + size_change_notifier); + DeviceState *dev =3D DEVICE(pci_mem); + const uint64_t * const size_p =3D data; + const char *id =3D NULL; + + if (dev->id) { + id =3D g_strdup(dev->id); + } + + qapi_event_send_memory_device_size_change(!!id, id, *size_p); +} + static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -98,9 +114,21 @@ static void virtio_mem_pci_class_init(ObjectClass *klas= s, void *data) static void virtio_mem_pci_instance_init(Object *obj) { VirtIOMEMPCI *dev =3D VIRTIO_MEM_PCI(obj); + VirtIOMEMClass *vmc; + VirtIOMEM *vmem; =20 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_MEM); + + dev->size_change_notifier.notify =3D virtio_mem_pci_size_change_notify; + vmem =3D VIRTIO_MEM(&dev->vdev); + vmc =3D VIRTIO_MEM_GET_CLASS(vmem); + /* + * We never remove the notifier again, as we expect both devices to + * disappear at the same time. + */ + vmc->add_size_change_notifier(vmem, &dev->size_change_notifier); + object_property_add_alias(obj, VIRTIO_MEM_BLOCK_SIZE_PROP, OBJECT(&dev->vdev), VIRTIO_MEM_BLOCK_SIZE_PR= OP); object_property_add_alias(obj, VIRTIO_MEM_SIZE_PROP, OBJECT(&dev->vdev= ), diff --git a/monitor/monitor.c b/monitor/monitor.c index 125494410a..19dcb8fbe3 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -235,6 +235,7 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAP= I_EVENT__MAX] =3D { [QAPI_EVENT_QUORUM_REPORT_BAD] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_QUORUM_FAILURE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_VSERPORT_CHANGE] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] =3D { 1000 * SCALE_MS }, }; =20 /* --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888578; cv=none; d=zohomail.com; s=zohoarc; b=b1WyHGHWejw6m3Xc2h26pQ+XDNPU4c3BqFArELdqCvvgQ1vZ4VZzWTaK22bYAaJ5YdhZOxXfoyREG0qSiRaC5WPD1nRAfHMmTokh0un9nPXpJfVAmalOK5xvn4Tbx+DD/fRQ5EMRFVAkuN5qetYZPWUKaSiDZHouCQjBhEYki5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888578; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f9CmOk570qqW369cDnLY15y4/98kzCoPRNo7La5usU4=; b=hwa3j7UzX8E01mxq3rrsUYZnzGGlPpkLWY6aYwrBo7BUWUns6ye3N7udsuYdAV9tEyFZlbJjW80ZB5fME/bFYGW0Mj2DFfwpsfKJefonPNdT1eIZViX+br5IPSHJTHV9vlNPPppatpjnS2tuly3OY4BdqswGeyJ7VRf7MD493sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888578728780.6072736531723; Sat, 4 Jul 2020 11:49:38 -0700 (PDT) Received: from localhost ([::1]:58298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnEH-0007Zt-Ea for importer@patchew.org; Sat, 04 Jul 2020 14:49:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmyH-00082I-5e for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:33:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32261 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmyF-0001ua-Bj for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:33:04 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-R__HX3mAMXuUmu8rFJKLbQ-1; Sat, 04 Jul 2020 14:30:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id w4so34406406wrm.5 for ; Sat, 04 Jul 2020 11:30:22 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id a12sm17216825wrv.41.2020.07.04.11.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f9CmOk570qqW369cDnLY15y4/98kzCoPRNo7La5usU4=; b=OSWq08BwZJrWKPfvwuRirruz8GUN5tR1L/7EAfNm+yZ8xw6jCfpynib4YH0YyA7aqsEDQ+ dSF4NGa9I9KwDxVIoVqQV4N1eDGf1lRJzovzzO5aomxSBDpGd1xoT24beiEzlW0QIHbrm9 oX76W8TYuINAh3xXHs0ioruHgX5qpfo= X-MC-Unique: R__HX3mAMXuUmu8rFJKLbQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=f9CmOk570qqW369cDnLY15y4/98kzCoPRNo7La5usU4=; b=YszIykiekzcSP6P32VCKs/83RIpCPFov1GCCAGtG/AS7MgAioqRk4X/yZByJMe6XGO rbEySKCUMU3D46I7WcKd1hPFtQCFOvbsWA1JagbcYzQMCxeZJuYSEzOf3EsdoAj/nshO SS02V48MtIFFXSIhQneenHOk3uEDdYgCloS6+WsfyjDpPTgJKnsJkJFGXNTfgEpHNXif KOoWEnyUZ7t9eaLyaIdrDVoDgTL73jBqKGa9E5B4X2MXbksH4tT75ZYk5ToB54uQvVaB ULc1cxebDiYUvYVaPoU1tlnAl4U2QUAhOoy5vPu6zvOzvzUwxsDtxpNNcrne0cHhQ208 WknQ== X-Gm-Message-State: AOAM531BrgW0UOSU34TmXwpr5O3GUH0zD+R8h1n5ImJ4bRr7ym/7uOld P91UwZ1zuOP7PXNIPIUVTaFqSMaNTijRyh9AH6VeuUFIgW26oXcx9pnBvR93MSwT+9ppMaHRJVY Ci6BUprs08ighGhw= X-Received: by 2002:a5d:62d1:: with SMTP id o17mr40656391wrv.162.1593887421695; Sat, 04 Jul 2020 11:30:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqlAMQC8hleja2NYtJmGvEo3Snu7cy7SeZlnM621efYHNHwMEOkWDHth3fej9uAKTrrEWFqA== X-Received: by 2002:a5d:62d1:: with SMTP id o17mr40656384wrv.162.1593887421531; Sat, 04 Jul 2020 11:30:21 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 21/41] virtio-mem: Migration sanity checks Message-ID: <20200704182750.1088103-22-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr . David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We want to make sure that certain properties don't change during migration, especially to catch user errors in a nice way. Let's migrate a temporary structure and validate that the properties didn't change. Reviewed-by: Dr. David Alan Gilbert Cc: "Michael S. Tsirkin" Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-19-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 6b5551515d..c1acfb9f24 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -519,12 +519,82 @@ static int virtio_mem_post_load(void *opaque, int ver= sion_id) return virtio_mem_restore_unplugged(VIRTIO_MEM(opaque)); } =20 +typedef struct VirtIOMEMMigSanityChecks { + VirtIOMEM *parent; + uint64_t addr; + uint64_t region_size; + uint64_t block_size; + uint32_t node; +} VirtIOMEMMigSanityChecks; + +static int virtio_mem_mig_sanity_checks_pre_save(void *opaque) +{ + VirtIOMEMMigSanityChecks *tmp =3D opaque; + VirtIOMEM *vmem =3D tmp->parent; + + tmp->addr =3D vmem->addr; + tmp->region_size =3D memory_region_size(&vmem->memdev->mr); + tmp->block_size =3D vmem->block_size; + tmp->node =3D vmem->node; + return 0; +} + +static int virtio_mem_mig_sanity_checks_post_load(void *opaque, int versio= n_id) +{ + VirtIOMEMMigSanityChecks *tmp =3D opaque; + VirtIOMEM *vmem =3D tmp->parent; + const uint64_t new_region_size =3D memory_region_size(&vmem->memdev->m= r); + + if (tmp->addr !=3D vmem->addr) { + error_report("Property '%s' changed from 0x%" PRIx64 " to 0x%" PRI= x64, + VIRTIO_MEM_ADDR_PROP, tmp->addr, vmem->addr); + return -EINVAL; + } + /* + * Note: Preparation for resizeable memory regions. The maximum size + * of the memory region must not change during migration. + */ + if (tmp->region_size !=3D new_region_size) { + error_report("Property '%s' size changed from 0x%" PRIx64 " to 0x%" + PRIx64, VIRTIO_MEM_MEMDEV_PROP, tmp->region_size, + new_region_size); + return -EINVAL; + } + if (tmp->block_size !=3D vmem->block_size) { + error_report("Property '%s' changed from 0x%" PRIx64 " to 0x%" PRI= x64, + VIRTIO_MEM_BLOCK_SIZE_PROP, tmp->block_size, + vmem->block_size); + return -EINVAL; + } + if (tmp->node !=3D vmem->node) { + error_report("Property '%s' changed from %" PRIu32 " to %" PRIu32, + VIRTIO_MEM_NODE_PROP, tmp->node, vmem->node); + return -EINVAL; + } + return 0; +} + +static const VMStateDescription vmstate_virtio_mem_sanity_checks =3D { + .name =3D "virtio-mem-device/sanity-checks", + .pre_save =3D virtio_mem_mig_sanity_checks_pre_save, + .post_load =3D virtio_mem_mig_sanity_checks_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(addr, VirtIOMEMMigSanityChecks), + VMSTATE_UINT64(region_size, VirtIOMEMMigSanityChecks), + VMSTATE_UINT64(block_size, VirtIOMEMMigSanityChecks), + VMSTATE_UINT32(node, VirtIOMEMMigSanityChecks), + VMSTATE_END_OF_LIST(), + }, +}; + static const VMStateDescription vmstate_virtio_mem_device =3D { .name =3D "virtio-mem-device", .minimum_version_id =3D 1, .version_id =3D 1, .post_load =3D virtio_mem_post_load, .fields =3D (VMStateField[]) { + VMSTATE_WITH_TMP(VirtIOMEM, VirtIOMEMMigSanityChecks, + vmstate_virtio_mem_sanity_checks), VMSTATE_UINT64(usable_region_size, VirtIOMEM), VMSTATE_UINT64(size, VirtIOMEM), VMSTATE_UINT64(requested_size, VirtIOMEM), --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888286; cv=none; d=zohomail.com; s=zohoarc; b=e31LmvjnU+pWuaAetFW9qVQik2IDTDqXBM3Spo9Igl3I+GMhtyViqZ7HIttnpmMHEqjvbXD+wEMYs+q4Oa849Eqr1Gf+ovnUV25OgdsziTpb+cT45ZQU8OQopbTW9+U1hg48nv9jZjJ6zha/mPzMGzQSvsEL09pmnJSi1swmhHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888286; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KULQLlGiQfzvNo12aiX0oUpGc53U/gZ4NdWwsgxfmhU=; b=EFEW1hK+CZCyvWLsGOKzTe2MpjHsBaXRnq+E5IRjZ1JbEiTIacRqqC3cRln3SUhiDixYOIUWQH74AeznnmDsl5PUgAdq7H7yWxSSliOzXOLwiKM+08yAB7k2oMBTHqQpyebT0RlGWjkPa5lbM/3xQg2ES82fOUNU0DcIlRHTRUk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888286014197.99259405718317; Sat, 4 Jul 2020 11:44:46 -0700 (PDT) Received: from localhost ([::1]:59276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn9Y-0004Nd-Px for importer@patchew.org; Sat, 04 Jul 2020 14:44:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvm-0003pV-22 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42802 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvk-0001QW-1b for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:29 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-wLUrGXxzOa2vx6bhHzJYeg-1; Sat, 04 Jul 2020 14:30:25 -0400 Received: by mail-wr1-f71.google.com with SMTP id j16so31064517wrw.3 for ; Sat, 04 Jul 2020 11:30:25 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id a12sm17216923wrv.41.2020.07.04.11.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KULQLlGiQfzvNo12aiX0oUpGc53U/gZ4NdWwsgxfmhU=; b=QApAm9qYzJgYEr+OiISq78IoHjNm8M9WMBS6Im+Hdl+bYIQUfp6JTY/4wE7I70Up2IatnZ nptBRgjBPNUk21/RIq9UUElJwOzsR0iwjRS5d0LxBWlTaJnbw75amguBxopCgMpckOCrfH yPtL9hK/tpmdauBVlcpCnfKhIv0TMqI= X-MC-Unique: wLUrGXxzOa2vx6bhHzJYeg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KULQLlGiQfzvNo12aiX0oUpGc53U/gZ4NdWwsgxfmhU=; b=PeRWQTgXaDiwLmN6nyCJBHZ1WC9v6PRDd2E0tSNNwI2p7vrukhW0bDBOxS+qaF4EVT hksE8xQgK2+emzzbwPvpM3yKSnHlpXWjJEmUAACjhQVZDsxX5BqpsnTRQKqKZE/zNBl6 8051eYPLy4VPOLg4A2bWyhJ4ZGzGww7CacJIEUjsfozwArAIurMq/6R1lnsnS+6NOlPP kkfJSr6AKgAn8vNPCrNMJkegm4VmeVVF6Erb/FsByg4J5xYZps0sPFXacVJSg1uAbT14 MyOodU8uVswS9egEBjOC1MTrvbZMBf4cI8tob2Qa451E8Skco5Fe4ctccyz97RwdS6A2 6HSg== X-Gm-Message-State: AOAM533W+hfedjK2zlf67s8qwKyJ0nxLaY5ntdB7b7pbfv7LpXTbgf01 XX2rJOnUs2eTeXyNJ73c12ArMc9H6yWuTqBAgfH3kWe6EAJsYAqI9SZHsBCzxI1g/YRvdP/fGTn Gd6McGSVSdKjnjI8= X-Received: by 2002:a5d:6603:: with SMTP id n3mr43347960wru.142.1593887424055; Sat, 04 Jul 2020 11:30:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQP/EgEc8Ow9qF7K9idblwusMCRaIET4RU0t9kMLP8wzP2YtRIFwSC7fEU0uDTOwIoQRSs8w== X-Received: by 2002:a5d:6603:: with SMTP id n3mr43347953wru.142.1593887423881; Sat, 04 Jul 2020 11:30:23 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 22/41] virtio-mem: Add trace events Message-ID: <20200704182750.1088103-23-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr. David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's add some trace events that might come in handy later. Cc: "Michael S. Tsirkin" Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-20-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 10 +++++++++- hw/virtio/trace-events | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index c1acfb9f24..1ab9ef17fa 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -30,6 +30,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "config-devices.h" +#include "trace.h" =20 /* * Use QEMU_VMALLOC_ALIGN, so no THP will have to be split when unplugging @@ -100,6 +101,7 @@ static void virtio_mem_send_response(VirtIOMEM *vmem, V= irtQueueElement *elem, VirtIODevice *vdev =3D VIRTIO_DEVICE(vmem); VirtQueue *vq =3D vmem->vq; =20 + trace_virtio_mem_send_response(le16_to_cpu(resp->type)); iov_from_buf(elem->in_sg, elem->in_num, 0, resp, sizeof(*resp)); =20 virtqueue_push(vq, elem, sizeof(*resp)); @@ -195,6 +197,7 @@ static void virtio_mem_plug_request(VirtIOMEM *vmem, Vi= rtQueueElement *elem, const uint16_t nb_blocks =3D le16_to_cpu(req->u.plug.nb_blocks); uint16_t type; =20 + trace_virtio_mem_plug_request(gpa, nb_blocks); type =3D virtio_mem_state_change_request(vmem, gpa, nb_blocks, true); virtio_mem_send_response_simple(vmem, elem, type); } @@ -206,6 +209,7 @@ static void virtio_mem_unplug_request(VirtIOMEM *vmem, = VirtQueueElement *elem, const uint16_t nb_blocks =3D le16_to_cpu(req->u.unplug.nb_blocks); uint16_t type; =20 + trace_virtio_mem_unplug_request(gpa, nb_blocks); type =3D virtio_mem_state_change_request(vmem, gpa, nb_blocks, false); virtio_mem_send_response_simple(vmem, elem, type); } @@ -225,6 +229,7 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *= vmem, return; } =20 + trace_virtio_mem_resized_usable_region(vmem->usable_region_size, newsi= ze); vmem->usable_region_size =3D newsize; } =20 @@ -247,7 +252,7 @@ static int virtio_mem_unplug_all(VirtIOMEM *vmem) vmem->size =3D 0; notifier_list_notify(&vmem->size_change_notifiers, &vmem->size); } - + trace_virtio_mem_unplugged_all(); virtio_mem_resize_usable_region(vmem, vmem->requested_size, true); return 0; } @@ -255,6 +260,7 @@ static int virtio_mem_unplug_all(VirtIOMEM *vmem) static void virtio_mem_unplug_all_request(VirtIOMEM *vmem, VirtQueueElement *elem) { + trace_virtio_mem_unplug_all_request(); if (virtio_mem_unplug_all(vmem)) { virtio_mem_send_response_simple(vmem, elem, VIRTIO_MEM_RESP_BUSY); } else { @@ -272,6 +278,7 @@ static void virtio_mem_state_request(VirtIOMEM *vmem, V= irtQueueElement *elem, .type =3D cpu_to_le16(VIRTIO_MEM_RESP_ACK), }; =20 + trace_virtio_mem_state_request(gpa, nb_blocks); if (!virtio_mem_valid_range(vmem, gpa, size)) { virtio_mem_send_response_simple(vmem, elem, VIRTIO_MEM_RESP_ERROR); return; @@ -284,6 +291,7 @@ static void virtio_mem_state_request(VirtIOMEM *vmem, V= irtQueueElement *elem, } else { resp.u.state.state =3D cpu_to_le16(VIRTIO_MEM_STATE_MIXED); } + trace_virtio_mem_state_response(le16_to_cpu(resp.u.state.state)); virtio_mem_send_response(vmem, elem, &resp); } =20 diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 6427a0047d..292fc15e29 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -74,3 +74,13 @@ virtio_iommu_get_domain(uint32_t domain_id) "Alloc domai= n=3D%d" virtio_iommu_put_domain(uint32_t domain_id) "Free domain=3D%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_= t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=3D%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoin= t, uint64_t addr) "FAULT reason=3D%d flags=3D%d endpoint=3D%d address =3D0x= %"PRIx64 + +# virtio-mem.c +virtio_mem_send_response(uint16_t type) "type=3D%" PRIu16 +virtio_mem_plug_request(uint64_t addr, uint16_t nb_blocks) "addr=3D0x%" PR= Ix64 " nb_blocks=3D%" PRIu16 +virtio_mem_unplug_request(uint64_t addr, uint16_t nb_blocks) "addr=3D0x%" = PRIx64 " nb_blocks=3D%" PRIu16 +virtio_mem_unplugged_all(void) "" +virtio_mem_unplug_all_request(void) "" +virtio_mem_resized_usable_region(uint64_t old_size, uint64_t new_size) "ol= d_size=3D0x%" PRIx64 "new_size=3D0x%" PRIx64 +virtio_mem_state_request(uint64_t addr, uint16_t nb_blocks) "addr=3D0x%" P= RIx64 " nb_blocks=3D%" PRIu16 +virtio_mem_state_response(uint16_t state) "state=3D%" PRIu16 --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888388; cv=none; d=zohomail.com; s=zohoarc; b=cEIXDLWJMazJ1xih8o9Fh/mW3TgkO4nYrHfQBLiLBxoGKCl/IpwX8P6AoMMRZBhG0ia+qjJvegXpOv6bIZXEs1+T/tH29Pt9vs1mXcqxxBT2uSdZSYwG7h8eQ8lqY53wpEuY6hqEgsz0cWH2Ln/KqTYVVVqDDDN4JYA03VSGvso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888388; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=84z48SEDVIW4lHeSX/JWrxebkeh/PVqSS0PAVUgtM8I=; b=fXv/Jyju+I1/HBLdVZukpLMys7AEI1NlCLqQodMFObpic6HTYsTBNUHdZsI2ZX3VitedBJv8hKlEaRiGabtEB1jvn8H0/d9KyPPmII8kOwFaOpSMgl4i2TfrI2Q3lpK4Ksh6nFmWSbfYzJbt0kHwvWQg7USNFkqB23Dyhu9a7ls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888388145442.3000013357463; Sat, 4 Jul 2020 11:46:28 -0700 (PDT) Received: from localhost ([::1]:39502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnBC-0007zA-U4 for importer@patchew.org; Sat, 04 Jul 2020 14:46:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvo-0003vJ-Ks for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:32 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:44007 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvm-0001RI-Fs for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:32 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-a_3ua2UjPuWPZdA0SB0H-w-1; Sat, 04 Jul 2020 14:30:27 -0400 Received: by mail-wr1-f69.google.com with SMTP id g14so36341439wrp.8 for ; Sat, 04 Jul 2020 11:30:27 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 63sm18751488wra.86.2020.07.04.11.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=84z48SEDVIW4lHeSX/JWrxebkeh/PVqSS0PAVUgtM8I=; b=JLo6mZ/24MQCs4AXwIAUSXr7r9dd0Ro7E12sIP2uiQyduIAr/4PfB+tw82PCgdBxvO4rL2 dXvQBi1ZG3g7xjl0sY5wj/nGgdvEUUa6ueusdyd2KgcvGdu/7F986QZCSJgxi7vJW3GGqR K1dGdQN16zUE13XOOMRJruiiKYz3zK8= X-MC-Unique: a_3ua2UjPuWPZdA0SB0H-w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=84z48SEDVIW4lHeSX/JWrxebkeh/PVqSS0PAVUgtM8I=; b=nujsIOjand6hj+9ms2NvNdT1YnTAv+xWVbyOTT45mMYO35LBQpBEngy1OEoNDBEHlv sAeG5F2BLgfvlqFnwT8R94KjGXJefQi+HdoyhNgonWtydMf3giFbIQPT2hSrBK1XC11Q /KP4LR9QmRt/0TMl3nb0plaI7xXMAges9y63ZEbt5O1xwNMWrAJc2crz/fK2r3Kr6lNj EWRFBt4mZaDRCkBFfV29idZfAw/GtUbwD9GKKLcr0tgcVq24R5mMdhwgjqATyhOtONxx 7NLXR6bAV5cQAXY9sAOCKZYJKPoyfR7p+8GOIevvjNkgzrkNqN6si2GsclmVUGzId5rh vaGw== X-Gm-Message-State: AOAM532o2/Np/UI2roDBb6E7IzHPRQYlID0TUPq/g/zTh6dunsg4Inqw b/WIiCWGJBtv+9EkuyKEvzIu72aijhxJ+o7DesoQQcjTmW1N2yN4ckQEBuFaiQJ1FdEMbCMGc51 tb6qiWPsJOLGaTjQ= X-Received: by 2002:a1c:99c2:: with SMTP id b185mr44654505wme.52.1593887426468; Sat, 04 Jul 2020 11:30:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCryA6dX+fL8OLR9fS6X8IAgPieuRlD7P/JDWyluu3Ky07a5hGBsjv+Vy4/u11a5MxEI8B2w== X-Received: by 2002:a1c:99c2:: with SMTP id b185mr44654495wme.52.1593887426294; Sat, 04 Jul 2020 11:30:26 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 23/41] virtio-mem: Exclude unplugged memory during migration Message-ID: <20200704182750.1088103-24-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr. David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The content of unplugged memory is undefined and should not be migrated, ever. Exclude all unplugged memory during precopy using the precopy notifier infrastructure introduced for free page hinting in virtio-balloon. Unplugged memory is marked as "not dirty", meaning it won't be considered for migration. Cc: "Michael S. Tsirkin" Cc: "Dr. David Alan Gilbert" Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-21-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-mem.h | 3 ++ hw/virtio/virtio-mem.c | 54 +++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h index b74c77cd42..0778224964 100644 --- a/include/hw/virtio/virtio-mem.h +++ b/include/hw/virtio/virtio-mem.h @@ -67,6 +67,9 @@ typedef struct VirtIOMEM { =20 /* notifiers to notify when "size" changes */ NotifierList size_change_notifiers; + + /* don't migrate unplugged memory */ + NotifierWithReturn precopy_notifier; } VirtIOMEM; =20 typedef struct VirtIOMEMClass { diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 1ab9ef17fa..65850530e7 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -62,8 +62,14 @@ static bool virtio_mem_is_busy(void) /* * Postcopy cannot handle concurrent discards and we don't want to mig= rate * pages on-demand with stale content when plugging new blocks. + * + * For precopy, we don't want unplugged blocks in our migration stream= , and + * when plugging new blocks, the page content might differ between sou= rce + * and destination (observable by the guest when not initializing pages + * after plugging them) until we're running on the destination (as we = didn't + * migrate these blocks when they were unplugged). */ - return migration_in_incoming_postcopy(); + return migration_in_incoming_postcopy() || !migration_is_idle(); } =20 static bool virtio_mem_test_bitmap(VirtIOMEM *vmem, uint64_t start_gpa, @@ -475,6 +481,7 @@ static void virtio_mem_device_realize(DeviceState *dev,= Error **errp) host_memory_backend_set_mapped(vmem->memdev, true); vmstate_register_ram(&vmem->memdev->mr, DEVICE(vmem)); qemu_register_reset(virtio_mem_system_reset, vmem); + precopy_add_notifier(&vmem->precopy_notifier); } =20 static void virtio_mem_device_unrealize(DeviceState *dev) @@ -482,6 +489,7 @@ static void virtio_mem_device_unrealize(DeviceState *de= v) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOMEM *vmem =3D VIRTIO_MEM(dev); =20 + precopy_remove_notifier(&vmem->precopy_notifier); qemu_unregister_reset(virtio_mem_system_reset, vmem); vmstate_unregister_ram(&vmem->memdev->mr, DEVICE(vmem)); host_memory_backend_set_mapped(vmem->memdev, false); @@ -757,12 +765,56 @@ static void virtio_mem_set_block_size(Object *obj, Vi= sitor *v, const char *name, vmem->block_size =3D value; } =20 +static void virtio_mem_precopy_exclude_unplugged(VirtIOMEM *vmem) +{ + void * const host =3D qemu_ram_get_host_addr(vmem->memdev->mr.ram_bloc= k); + unsigned long first_zero_bit, last_zero_bit; + uint64_t offset, length; + + /* + * Find consecutive unplugged blocks and exclude them from migration. + * + * Note: Blocks cannot get (un)plugged during precopy, no locking need= ed. + */ + first_zero_bit =3D find_first_zero_bit(vmem->bitmap, vmem->bitmap_size= ); + while (first_zero_bit < vmem->bitmap_size) { + offset =3D first_zero_bit * vmem->block_size; + last_zero_bit =3D find_next_bit(vmem->bitmap, vmem->bitmap_size, + first_zero_bit + 1) - 1; + length =3D (last_zero_bit - first_zero_bit + 1) * vmem->block_size; + + qemu_guest_free_page_hint(host + offset, length); + first_zero_bit =3D find_next_zero_bit(vmem->bitmap, vmem->bitmap_s= ize, + last_zero_bit + 2); + } +} + +static int virtio_mem_precopy_notify(NotifierWithReturn *n, void *data) +{ + VirtIOMEM *vmem =3D container_of(n, VirtIOMEM, precopy_notifier); + PrecopyNotifyData *pnd =3D data; + + switch (pnd->reason) { + case PRECOPY_NOTIFY_SETUP: + precopy_enable_free_page_optimization(); + break; + case PRECOPY_NOTIFY_AFTER_BITMAP_SYNC: + virtio_mem_precopy_exclude_unplugged(vmem); + break; + default: + break; + } + + return 0; +} + static void virtio_mem_instance_init(Object *obj) { VirtIOMEM *vmem =3D VIRTIO_MEM(obj); =20 vmem->block_size =3D VIRTIO_MEM_MIN_BLOCK_SIZE; notifier_list_init(&vmem->size_change_notifiers); + vmem->precopy_notifier.notify =3D virtio_mem_precopy_notify; =20 object_property_add(obj, VIRTIO_MEM_SIZE_PROP, "size", virtio_mem_get_= size, NULL, NULL, NULL); --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887728; cv=none; d=zohomail.com; s=zohoarc; b=YLrcl8R+CIyIt0TCKbmgHqfB3sEpeOF1OOeJcDgkXnlh1qSiFSSUzXmxh/8AjXPs/RcplabG8B5HeQ4aOdb+luyNbjKxHlUAOhMLfOLHlepwwZMCkqzlLg4ejjpbghPh2GKb1jxLge5me7jgpKgQc1crU5t8v7g3wJqnr6vAWBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887728; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c5tdu84EsYu030A7xZkXJlQoGtXOTX2WueiDbJOGS4I=; b=ORrV9UgCgjs33jCBrpgHoaTwsVzGt4A8BDjWgmNvrf5UBMEHW+jmgyGT/MbvCKlBLpeJFwfp3raJIPbQNVTLpdVA1/5TSoDAZaN38Dah0cYu7gvEsCW+SZ2yfqjNNSSRvrThjyxkpmVr97jBFq9pApYte9foFx1chACVncMyswA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887728654132.0375304318295; Sat, 4 Jul 2020 11:35:28 -0700 (PDT) Received: from localhost ([::1]:49694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn0Z-00044N-Ee for importer@patchew.org; Sat, 04 Jul 2020 14:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvr-00043b-6j for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:35 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35555 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvp-0001SN-9h for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:34 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-AqOa_4JaN1ihcmqFC1wqfA-1; Sat, 04 Jul 2020 14:30:30 -0400 Received: by mail-wr1-f71.google.com with SMTP id g14so36341498wrp.8 for ; Sat, 04 Jul 2020 11:30:30 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 138sm11807123wmb.1.2020.07.04.11.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c5tdu84EsYu030A7xZkXJlQoGtXOTX2WueiDbJOGS4I=; b=aZXbCez874WMXryFVKQ8JC4F+yfBFgqQVPgmcw5Ld83iOVD2aISTwQ8LfUD/xBYaIp/AZb wk2ohByiYPPyo/hyYc3U8QuJ8+orWY6nFBnlQNNJ2+E4ynKJiaMvOgCMOoXlycmmIXkeKe a8K9P5HBhHhPpCkTsPE88B0Kj5PYLtc= X-MC-Unique: AqOa_4JaN1ihcmqFC1wqfA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=c5tdu84EsYu030A7xZkXJlQoGtXOTX2WueiDbJOGS4I=; b=p4HTvgHg81A7PK2DGfYbaPz3y0Ij5aJ7zzFwZsePsQgnrzcP1RoeCyB8ggkmD7B6EV jf/qGxffB208TbU5WjckS4VOcNV/05QZaOkDr/gaf4yh6mC7aUHf3vtp7GJkS4FjuwNu gA+IdXNRD9tU4k5+KaxfmkTqJ9XA2IilhhZ30mQ7xLaICHvFH45QnTg7wedSt474iwUH NUyhvVqxHfNZXPA2HB5z9667MyIrwRpzXEjXr9LVHZZ1pLwggSQFTXNw8yoKB+7TJFe+ c0cTpjNNCWjy7j1LX0alDs1YOjeNGO9fnBd2aDx61riHSVe2HsoefafmbVkRcOfLuE4k tzlg== X-Gm-Message-State: AOAM531oXkPnsRVEU1nvb9GiguBR3GwAhvHDFU1oQr9Pe79sra9M5bHG NohUkQZTsVg/tejJ6vL8R2eY6QwtEisva3xumDDsRI2dU4ETmye8GdRMUTrSw2s5AwecHyNnITt 45GnNsyfOaxxFU4s= X-Received: by 2002:a1c:2543:: with SMTP id l64mr19623190wml.31.1593887429326; Sat, 04 Jul 2020 11:30:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbftQgMyYBvfKSH1NN+PJnw9GEpP/PW/wYMk4Mirry8BFPzZZt51zy13T+uqR+sMV7gMfuAg== X-Received: by 2002:a1c:2543:: with SMTP id l64mr19623173wml.31.1593887429065; Sat, 04 Jul 2020 11:30:29 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 24/41] numa: Auto-enable NUMA when any memory devices are possible Message-ID: <20200704182750.1088103-25-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Sergio Lopez , David Hildenbrand , "qemu-arm @ nongnu . org" , Igor Mammedov , Paolo Bonzini , Alex Shi , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's auto-enable it also when maxmem is specified but no slots are defined. This will result in us properly creating ACPI srat tables, indicating the maximum possible PFN to the guest OS. Based on this, e.g., Linux will enable the swiotlb properly. This avoids having to manually force the switolb on (swiotlb=3Dforce) in Linux in case we're booting only using DMA memory (e.g., 2GB on x86-64), and virtio-mem adds memory later on that really needs the swiotlb to be used for DMA. Let's take care of backwards compatibility if somebody has a setup that specifies "maxram" without "slots". Reported-by: Alex Shi Cc: Peter Maydell Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Sergio Lopez Cc: Paolo Bonzini Cc: Richard Henderson Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: qemu-arm@nongnu.org Signed-off-by: David Hildenbrand Message-Id: <20200626072248.78761-22-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/boards.h | 1 + hw/arm/virt.c | 2 ++ hw/core/numa.c | 11 ++++++----- hw/i386/microvm.c | 1 + hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 18815d9be2..426ce5f625 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -207,6 +207,7 @@ struct MachineClass { const char **valid_cpu_types; strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; + bool auto_enable_numa_with_memdev; void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); bool ignore_boot_device_suffixes; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cd0834ce7f..f97be80a86 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2373,6 +2373,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) hc->unplug =3D virt_machine_device_unplug_cb; mc->nvdimm_supported =3D true; mc->auto_enable_numa_with_memhp =3D true; + mc->auto_enable_numa_with_memdev =3D true; mc->default_ram_id =3D "mach-virt.ram"; =20 object_class_property_add(oc, "acpi", "OnOffAuto", @@ -2485,6 +2486,7 @@ static void virt_machine_5_0_options(MachineClass *mc) virt_machine_5_1_options(mc); compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len); mc->numa_mem_supported =3D true; + mc->auto_enable_numa_with_memdev =3D false; } DEFINE_VIRT_MACHINE(5, 0) =20 diff --git a/hw/core/numa.c b/hw/core/numa.c index e9aec69afd..6a20ce7cf1 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -688,8 +688,9 @@ void numa_complete_configuration(MachineState *ms) NodeInfo *numa_info =3D ms->numa_state->nodes; =20 /* - * If memory hotplug is enabled (slots > 0) but without '-numa' - * options explicitly on CLI, guestes will break. + * If memory hotplug is enabled (slot > 0) or memory devices are enabl= ed + * (ms->maxram_size > ram_size) but without '-numa' options explicitly= on + * CLI, guests will break. * * Windows: won't enable memory hotplug without SRAT table at all * @@ -704,9 +705,9 @@ void numa_complete_configuration(MachineState *ms) * assume there is just one node with whole RAM. */ if (ms->numa_state->num_nodes =3D=3D 0 && - ((ms->ram_slots > 0 && - mc->auto_enable_numa_with_memhp) || - mc->auto_enable_numa)) { + ((ms->ram_slots && mc->auto_enable_numa_with_memhp) || + (ms->maxram_size > ms->ram_size && mc->auto_enable_numa_with_memd= ev) || + mc->auto_enable_numa)) { NumaNodeOptions node =3D { }; parse_numa_node(ms, &node, &error_abort); numa_info[0].node_mem =3D ram_size; diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 5e931975a0..81d0888930 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -464,6 +464,7 @@ static void microvm_class_init(ObjectClass *oc, void *d= ata) mc->max_cpus =3D 288; mc->has_hotpluggable_cpus =3D false; mc->auto_enable_numa_with_memhp =3D false; + mc->auto_enable_numa_with_memdev =3D false; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D false; mc->default_ram_id =3D "microvm.ram"; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 576f2502f9..61acc9e530 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1975,6 +1975,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->get_default_cpu_node_id =3D x86_get_default_cpu_node_id; mc->possible_cpu_arch_ids =3D x86_possible_cpu_arch_ids; mc->auto_enable_numa_with_memhp =3D true; + mc->auto_enable_numa_with_memdev =3D true; mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; mc->hot_add_cpu =3D pc_hot_add_cpu; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1d832b2878..fae487f57d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -444,6 +444,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass = *m) m->numa_mem_supported =3D true; compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len); compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len); + m->auto_enable_numa_with_memdev =3D false; } =20 DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 047ea8db28..acd6d405f0 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -372,6 +372,7 @@ static void pc_q35_5_0_machine_options(MachineClass *m) m->numa_mem_supported =3D true; compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len); compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len); + m->auto_enable_numa_with_memhp =3D false; } =20 DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL, --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887959; cv=none; d=zohomail.com; s=zohoarc; b=h1xV8ccij/INGYmofvWOwQLEut9v44VSQFMrkJS/o85x1sDrZPiEpUWU2vPo+kc3SUC4wf9kvTFJ7wfWUrI96Bo4PulbeZXjJ6EkpZAJFYT6Bf8ySXS5mXLWHDk3iVgozOiAPXe5acBtncxJBrbolhclWMAV2+nrl6Mm4526ib8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887959; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=60yJhhl8dxn2TqcFbclvoZcJECXRC60a4szFbHzWcWo=; b=XvFTbidwIse5ZlEW6wcXjxExiXXLHbqaM00lK7W+tkAmvdxKUxmDo264UZbxTVjGlSJSjrsDmGC/A5xtH8wapGZVexdmiTJfdkezR5FwYE++1fwgcBVPrPpbXkiiOv5xIiV6aZ7gDmTeWKPFYu0GLUgHYqIFD4aqkZmDWUT15Pw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887959770856.8156105165632; Sat, 4 Jul 2020 11:39:19 -0700 (PDT) Received: from localhost ([::1]:36152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn4I-0002t6-Is for importer@patchew.org; Sat, 04 Jul 2020 14:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvt-00048t-5F for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:37 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58296 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvr-0001Tq-H3 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:36 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-405-LgZZ6kRHNMSyBNcwB5vkKA-1; Sat, 04 Jul 2020 14:30:33 -0400 Received: by mail-wm1-f72.google.com with SMTP id h6so40143249wmb.7 for ; Sat, 04 Jul 2020 11:30:32 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id g144sm48583037wme.2.2020.07.04.11.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=60yJhhl8dxn2TqcFbclvoZcJECXRC60a4szFbHzWcWo=; b=edc4sSsuhKUbusEx/YfHS5XjBWRkH+BvkmH/PLYBGbXj6S2Pxa5IZPU9A27IoYbRivBZHB L6tmYD2ulLVHXaPnvxBDY+N1+An5E/m45+cQnx4OIKyGXvWw61w9as/jOnhZWXMpefLYT4 Ticny7pTbXZkFPmYpFKWVFq+ty4xhNw= X-MC-Unique: LgZZ6kRHNMSyBNcwB5vkKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=60yJhhl8dxn2TqcFbclvoZcJECXRC60a4szFbHzWcWo=; b=lYhdSnRkyuXxnnydAomKmqPt030y06mDIjPNehSPPnMAlnNnZlFCvWO2cbNI19B7zV hUUyPY88ctKDvDCXXGvF/HljHhw30dwM2QFxSYp8bFLKfyM3OPpmPnofkMNPbdx+Jnb+ TdeDdpJVz1btPhfetJ/bd8OBuGr5yoeP8L2y6xdTVnn/kvY2EHV2NVmspO0fg48JnwUM PWa/HCurtu6/g5AmoRhU+kxtE/Bgm9x5BVS5yDTVTEhdsBg4HgJMJgcmzBODPnCn2/nX 6fIhAwDw2fHKPcA7u8YX7+jxjDPVoC/Akt87Ld9cK8s92O3MZgIHPjfcB/uI3nLAsGTg 4EKA== X-Gm-Message-State: AOAM533zTKT9TqUU2vEUrDFe+0LM0Z5PZXPc3iF8wr2n4SRa4nj/BEdb wfAQv6XuIhBat7UfadPPVASjoAMas7D/z/xTwjh/2gAdMCHDmxfdNOslgyHiLzBgL9pFmvXRXyt H/lVqe1LuQGrvbIY= X-Received: by 2002:a1c:dfc5:: with SMTP id w188mr12494695wmg.182.1593887431647; Sat, 04 Jul 2020 11:30:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx149yEMsm8MhTNYtnrIEgwNmK+jlhZLTOPwFecN/e87VSgUfRGE0ayITB8TAoeEQqsYdSofg== X-Received: by 2002:a1c:dfc5:: with SMTP id w188mr12494685wmg.182.1593887431500; Sat, 04 Jul 2020 11:30:31 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 25/41] tests/acpi: remove stale allowed tables Message-ID: <20200704182750.1088103-26-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SUBJ_WIPE_DEBT=1.004 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrew Jones Fixes: 93dd625f8bf7 ("tests/acpi: update expected data files") Signed-off-by: Andrew Jones Message-Id: <20200629140938.17566-2-drjones@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 8992f1f12b..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,19 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT", -"tests/data/acpi/pc/DSDT.acpihmat", -"tests/data/acpi/pc/DSDT.bridge", -"tests/data/acpi/pc/DSDT.cphp", -"tests/data/acpi/pc/DSDT.dimmpxm", -"tests/data/acpi/pc/DSDT.ipmikcs", -"tests/data/acpi/pc/DSDT.memhp", -"tests/data/acpi/pc/DSDT.numamem", -"tests/data/acpi/q35/DSDT", -"tests/data/acpi/q35/DSDT.acpihmat", -"tests/data/acpi/q35/DSDT.bridge", -"tests/data/acpi/q35/DSDT.cphp", -"tests/data/acpi/q35/DSDT.dimmpxm", -"tests/data/acpi/q35/DSDT.ipmibt", -"tests/data/acpi/q35/DSDT.memhp", -"tests/data/acpi/q35/DSDT.mmio64", -"tests/data/acpi/q35/DSDT.numamem", -"tests/data/acpi/q35/DSDT.tis", --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887853; cv=none; d=zohomail.com; s=zohoarc; b=e77mrnU1dDfIQUwQV6dnn5hIpWwn3eGyp6HErVhRVxwhbFnxR6BbVmNoCxbtuBfj1Ly/xmThWRncl+tsBA2OBRl1m/C4t7zOUEaCMgmfqE2y9x2fi5bFRWllJdrjlc/2CiT1w2rLgwrWRmjQnKG5Yfec8vcP6rD5ZyuSBE+YdUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887853; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XsBDJFEC04b3XTFz4nBxIO5zxhzyAGQ01hQLAAQIsGo=; b=c7MnAlRgkas9ApZOI61xM8ppsHAyCA9uW1GNyGISS5o1D3pVt6LOW+ttAMwkLkWiYCIvzyFm+/p9vWnG73dXKyHu8llhC8Irh0NQ49gXTN167yTP20AngnaNO4FIU/fgT6U6fHcMWXNboiOZKoxv+8svjIXzmPiWUHuxHOZE1cM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887853928332.0334165864392; Sat, 4 Jul 2020 11:37:33 -0700 (PDT) Received: from localhost ([::1]:58130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn2a-0000Lq-Nn for importer@patchew.org; Sat, 04 Jul 2020 14:37:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvz-0004ML-9S for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:54103 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvw-0001Xj-Mp for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:42 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-xBfikwVKOrS0kcJFDejFgg-1; Sat, 04 Jul 2020 14:30:35 -0400 Received: by mail-wm1-f69.google.com with SMTP id c124so7825798wme.0 for ; Sat, 04 Jul 2020 11:30:35 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id f186sm16994044wmf.29.2020.07.04.11.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XsBDJFEC04b3XTFz4nBxIO5zxhzyAGQ01hQLAAQIsGo=; b=TKcXwXe6okdOUuNDJNJ0qM/BnkbNCPX3kIK8OVARL3vPt1jmMGnecu/z9dtk+5JNWNq/+q /ilxFyfGARQwuegln2iy5jO3OYvEjfa42jHG/bRb4he+EI9GO13wYMh4770xrtAdSQtw+6 W3HGHP0ZbnzEoOJ1K4rklj7ELM+dZv8= X-MC-Unique: xBfikwVKOrS0kcJFDejFgg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XsBDJFEC04b3XTFz4nBxIO5zxhzyAGQ01hQLAAQIsGo=; b=APmC1bro6pLJfgg6I3XbfIotmjzDkZ3oCFIS8SP7POI9RH3fk3uNe3fM3qwtU6SRFE abunQp8yQaDVsg9IvLZaGmmzaJ8CuxX+6oAt2+7r94G9QMzd6HVemHUD4Z0yEsSVgZwe 1VLs+NgRHRUrXE0h0vXC+mpW18cAcCKGErZdlcLeizYKzx84iH+2QBeqUjKzIw6JNR9G NJZVhy/4mdHIdQHChQHxIaU2GBGq3s4cP2+d2Mn+8qzhcRuRcdtM7VeN6fKjKeI1BeB2 h08pn8v8WMdMZPnS04pWoBht1o8oTw8pnY4CORtz2ZMNcePQMfL3lp8n7k+pqXAzx6DX paRQ== X-Gm-Message-State: AOAM532402unXdoa3uo59JZTwHnNFBntdlrVcHKi22hOO+2CeT4S6Jij /X1IaVuewn5ISyd84pa1GGAkAfy7DHehvVmsg2i3QU6pFThwZT71waOYqr7qT9waI8jKkODCQ6l ibSdFnlOPHN8ikko= X-Received: by 2002:a5d:630d:: with SMTP id i13mr42318609wru.208.1593887434029; Sat, 04 Jul 2020 11:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE+d+B11E2636uIQUtE4bOl5JE4bt1NC/dCI/OQS5YDXnScNRdsGiXRRrxqpP+CS3F8o1mEg== X-Received: by 2002:a5d:630d:: with SMTP id i13mr42318599wru.208.1593887433878; Sat, 04 Jul 2020 11:30:33 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 26/41] docs: vhost-user: add Virtio status protocol feature Message-ID: <20200704182750.1088103-27-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Maxime Coquelin , Jason Wang , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maxime Coquelin This patch specifies the VHOST_USER_SET_STATUS and VHOST_USER_GET_STATUS requests, which are sent by the master to update and query the Virtio status in the backend. Signed-off-by: Maxime Coquelin Message-Id: <20200618134501.145747-1-maxime.coquelin@redhat.com> Acked-by: Jason Wang Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 688b7c6900..10e3e3475e 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -816,6 +816,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14 #define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15 + #define VHOST_USER_PROTOCOL_F_STATUS 16 =20 Master message types -------------------- @@ -1307,6 +1308,29 @@ Master message types ``VHOST_USER_ADD_MEM_REG`` message, this message is used to set and update the memory tables of the slave device. =20 +``VHOST_USER_SET_STATUS`` + :id: 39 + :equivalent ioctl: VHOST_VDPA_SET_STATUS + :slave payload: N/A + :master payload: ``u64`` + + When the ``VHOST_USER_PROTOCOL_F_STATUS`` protocol feature has been + successfully negotiated, this message is submitted by the master to + notify the backend with updated device status as defined in the Virtio + specification. + +``VHOST_USER_GET_STATUS`` + :id: 40 + :equivalent ioctl: VHOST_VDPA_GET_STATUS + :slave payload: ``u64`` + :master payload: N/A + + When the ``VHOST_USER_PROTOCOL_F_STATUS`` protocol feature has been + successfully negotiated, this message is submitted by the master to + query the backend for its device status as defined in the Virtio + specification. + + Slave message types ------------------- =20 --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888122; cv=none; d=zohomail.com; s=zohoarc; b=aNAoOkW4UCD2cQIzxFQDvirOm8YJQBMSbX/5QXexXzy5inOscXXpSM1lVxmH3XSWJoMTsbXNZLEYntRY6l02zP+0M4LoTxFu+f8zhrGKAVfGgRBhigmZ0nv0x/oLCUYQh333fixadeHFs83nki62KBd+V9zBUUI5ts5HosdQFF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888122; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b+cCdkPsrD4TM/VrIcZdX3Ig4P6coUYr9PkA+fapcI0=; b=dMfGaxTA6tGsbRSj8G95GKRskkoRIYGg8cyYuLHjfWYKOeqvEPOLiJ6X8Sl6f2W1Br3jTPJbTlUQyij5JOHY0zqSR+/MdFV259fycXvtselTRdCgMXdb0AARRMUsuIsAKBstsAvdyXwrBJWSZlS86OtLzbi2ApcmjtSR7tx0ssg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888122686256.0042657920727; Sat, 4 Jul 2020 11:42:02 -0700 (PDT) Received: from localhost ([::1]:44478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn6v-0006oG-6I for importer@patchew.org; Sat, 04 Jul 2020 14:42:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmvz-0004Ln-1H for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51546 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvw-0001XX-FT for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:42 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-AFZcn_qtODmrmunOpxQmPQ-1; Sat, 04 Jul 2020 14:30:38 -0400 Received: by mail-wm1-f70.google.com with SMTP id q20so30339225wme.3 for ; Sat, 04 Jul 2020 11:30:37 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id h13sm17293163wml.42.2020.07.04.11.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=b+cCdkPsrD4TM/VrIcZdX3Ig4P6coUYr9PkA+fapcI0=; b=e1YulLyXiCpI2QJ9eiDHP3JpdkO+9llBtnwK4W0yHpC6fl75YShZj30NXWfQNVu9pMoKbT HJtD0QoWZ3Q96i9LyF1czXcli52mfZ2ywLkiQMfbusmELqmft9Ax2gbSHisbMwqXHYGGzs o6QbfVtfdeOsM/iap6LgX9mekhusREM= X-MC-Unique: AFZcn_qtODmrmunOpxQmPQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=b+cCdkPsrD4TM/VrIcZdX3Ig4P6coUYr9PkA+fapcI0=; b=RXXqrn9kuiNPohMw3uD/XlwZ6ybWLSUTe2I1v0OboHY+CHsxLj4P3M4sDpXkHL3Xg+ pDFkjHfjyo725QmtzhJReeVUUXGQN934Fgrvcakxx5W8ffizJnITZaiZGE4oD+wz4Ckd sQjAypYM7EaY6GH09EFpecD4btFVd8EnKE7IfRhZHQRZ4GJjctOzgp98fSIkrbeV+oQl FQpICKe4duBygvlKMRpcoJzn2Ai4yg7cv8G2ISGuGwyDRsNeqJwwfb2oB3V/LBjDDzKt +YeEpRFz50/Fm583RUFcTZ0eVVWa3F8i+xEtg/80rIgVi6icqnLjEU/8u52Lw9zDyRrz jMNA== X-Gm-Message-State: AOAM532tivUtbk5cobPG+KsSXXcOriQ3fEc27b6Qhpa4iVg4hBiNRngB IuvZxhdk6nvhfuGhypFY6XZ/ssFu3PYlez8NZQ7c34QWeLRQBBwEaWt3DEv61PXN6Qve29QONZ/ bdB8mIc1u4JmoREg= X-Received: by 2002:a5d:6412:: with SMTP id z18mr40873158wru.310.1593887436656; Sat, 04 Jul 2020 11:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySJsC7pHE2exasR13nd1GGexOVm/Dg/X6BKJ49WB11jxf2N6CmEnfOyBDnB1jiIhqj3HGKbg== X-Received: by 2002:a5d:6412:: with SMTP id z18mr40873143wru.310.1593887436533; Sat, 04 Jul 2020 11:30:36 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 27/41] MAINTAINERS: add VT-d entry Message-ID: <20200704182750.1088103-28-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alex =?utf-8?Q?Benn=C3=A9e?= , Jason Wang , Laurent Vivier , Peter Xu , Aleksandar Markovic , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu Add this entry as suggested by Jason and Michael. CC: Jason Wang CC: Michael S. Tsirkin CC: Paolo Bonzini Signed-off-by: Peter Xu Message-Id: <20200701124418.63060-1-peterx@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5f02160436..49a0d837d7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2624,6 +2624,15 @@ F: tests/uefi-test-tools/ F: .gitlab-ci.d/edk2.yml F: .gitlab-ci.d/edk2/ =20 +VT-d Emulation +M: Michael S. Tsirkin +M: Peter Xu +R: Jason Wang +S: Supported +F: hw/i386/intel_iommu.c +F: hw/i386/intel_iommu_internal.h +F: include/hw/i386/intel_iommu.h + Usermode Emulation ------------------ Overall usermode emulation --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888476; cv=none; d=zohomail.com; s=zohoarc; b=Lk8xIt96K/ynf5hENPaJ5V1agVFgVJuZ1rZwkRhfNN/UKSyWe5FUCHsz8edHceK5XzWT8GQOJHs2MyU9F500SLJ0/l45HV9pJAy8NPM8wez0wFji7v7kut9IQ8LNOr1pHWxFTmHT0VcjkcY3T7joQsr1HMf9/B7X++VpL9OVviI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888476; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J87y6/ALZV5j2hxcU6iv08lRd5sVzb2p1LKaAZ1dyww=; b=X5aiRmViLBrkbPWf1jdrMCKBZHfleY9DBJfFHXiuJYHoPcCMXl7dmge6gnK3hPtHEO+6HsfhAHOPMgaeyYKWg5VcpIe2gBHZvbzkE5278XYEo1fDTxx0rAYznu6uA1xt3+XpRPe7+WDcXdwv3hEARxMWQ5kRcOJwbv12ajuWMa8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888476412905.2665554224377; Sat, 4 Jul 2020 11:47:56 -0700 (PDT) Received: from localhost ([::1]:47902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnCc-00038K-T6 for importer@patchew.org; Sat, 04 Jul 2020 14:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmw1-0004SD-D5 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:45 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39782 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmvz-0001ZW-If for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:45 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-AyTozNeVMruuGKquHZNywA-1; Sat, 04 Jul 2020 14:30:40 -0400 Received: by mail-wr1-f71.google.com with SMTP id o12so36257246wrj.23 for ; Sat, 04 Jul 2020 11:30:40 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id n5sm17021025wmi.34.2020.07.04.11.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=J87y6/ALZV5j2hxcU6iv08lRd5sVzb2p1LKaAZ1dyww=; b=AObpbMYK9w23uBXh5hkHDf8+Br5CubFu1BgE2C5bFB/lOnPsAbQA79WERoE2R7XNfnGYl8 rvC2t8WOobkIf9Zc6WnYxnabdOElT4bW4HGdpZJArv11i5ZPCbLuGBMx0l7C8BRLDlXdNr 9fLQ99bSS5deUEpzhlbK/Ajy2fp3mCI= X-MC-Unique: AyTozNeVMruuGKquHZNywA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J87y6/ALZV5j2hxcU6iv08lRd5sVzb2p1LKaAZ1dyww=; b=GSmyXOXsADFlUcdT8EPOOYeZ/SpQx89t9Pt1ACfomy1z5ylPA2g/ZIKu3rVlnYLFJJ xvhgsDlXwpQ+8uhL8JzG910/hRQLj5Px7afUTBhbrzbzYknf3joBeHYLKW9GO2pDGCqJ /WYi/z3YMCvipHISTCkRWtegVXVjTkXjwoPLktl6Zv3v3v47jUJ77coLk+I8cRrkojdf JVOiHved2gruRRhxjyvvvsX03WWP4KtpHI9eOMXlzOwqd3XeXA7byW9Wrh8KX/mbKfX6 mm0WWaN1Zo3lZCyelhuFYOP8vzq4D/t4feoljGZeqqPAjKGDXifv3FfgbqfQPz5QOX8J UgSw== X-Gm-Message-State: AOAM533CHY+CK3wa2kV5QuOEwN6RTmGJagT9rsPiJN9OeEi8qAT81VlX hVcTQHckxeYPVHnNuNzri/KKDFf2RAr2xRsZDwGS/CPy9IrPGinD2RCTfjGqXSaWO3cg3+nkAbT fjcW5xGiedFMyUnQ= X-Received: by 2002:a5d:650e:: with SMTP id x14mr43960653wru.187.1593887439019; Sat, 04 Jul 2020 11:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz3RWqFKTy2s8oJKuCMlVvqwFDWvlkuJXUzDI5CtWR4SB6EfithsyyitDICz3+tQY78T651A== X-Received: by 2002:a5d:650e:: with SMTP id x14mr43960644wru.187.1593887438879; Sat, 04 Jul 2020 11:30:38 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 28/41] net: introduce qemu_get_peer Message-ID: <20200704182750.1088103-29-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This is a small function that can get the peer from given NetClientState and queue_index Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-2-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/net/net.h | 1 + net/net.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 39085d9444..e7ef42d62b 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -176,6 +176,7 @@ void hmp_info_network(Monitor *mon, const QDict *qdict); void net_socket_rs_init(SocketReadState *rs, SocketReadStateFinalize *finalize, bool vnet_hdr); +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index); =20 /* NIC info */ =20 diff --git a/net/net.c b/net/net.c index d1130296e1..9099a327dd 100644 --- a/net/net.c +++ b/net/net.c @@ -325,6 +325,13 @@ void *qemu_get_nic_opaque(NetClientState *nc) return nic->opaque; } =20 +NetClientState *qemu_get_peer(NetClientState *nc, int queue_index) +{ + assert(nc !=3D NULL); + NetClientState *ncs =3D nc + queue_index; + return ncs->peer; +} + static void qemu_cleanup_net_client(NetClientState *nc) { QTAILQ_REMOVE(&net_clients, nc, next); --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593887986; cv=none; d=zohomail.com; s=zohoarc; b=O2tZTR8VadeFApP5MzSb74jbgotK8oJoWkY4naouIvt69Y3vPYZl6VAwvtjhB47JVL4In9rSI4jb8W84WKRkdrUwbDjgw3e8AwcwwH4VL2SZNFZ9dYzkRxbMBzEoqQXfDpR5Ek74RHLPv/pOHwpQiGjC/leDd0t3DYB6VYSbxpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593887986; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qOJsVqrCvYFr1+pi9ZUb1wgSPCHp9bN1XR/9RybzirU=; b=fwKrIMAZDIVn/tkL7cAog361m1vfQW3C7BaImdKLF+ae0ebc7S6JLfB1mEo5zltCvBPgRjfcuG7RKK3BViefr057Vc6wioCYeQg/0XgxVsfwxq5lG4IRwo430BQSze95+FpIES/n+t/Bsl34qHgwuCCzk85VlZlDnSnDJxTp2Pw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593887986125474.33885789869123; Sat, 4 Jul 2020 11:39:46 -0700 (PDT) Received: from localhost ([::1]:38278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn4i-0003is-Ty for importer@patchew.org; Sat, 04 Jul 2020 14:39:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmw3-0004WY-Mj for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26766 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmw2-0001bb-07 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:47 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-4lf72iiqM-C4nbueEmHeZw-1; Sat, 04 Jul 2020 14:30:43 -0400 Received: by mail-wm1-f69.google.com with SMTP id 65so20436641wmd.8 for ; Sat, 04 Jul 2020 11:30:42 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 59sm18305410wrj.37.2020.07.04.11.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qOJsVqrCvYFr1+pi9ZUb1wgSPCHp9bN1XR/9RybzirU=; b=USSuj4vjQDNoc9e8WWYpiOQkoFUWToxIv1ywJt/4jCXmkUj1YpSQ8qYsE5sGyzU5LsmOZ3 uKlXzqZlv6od4SFloy9Fdkx/tzGSd9ttD99ExsIkJfz6LeBUAWXXOQblIdFmin60aZtc/b Fn1Sa4JXQDcRyDelV09tp9ANBb2vl2U= X-MC-Unique: 4lf72iiqM-C4nbueEmHeZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qOJsVqrCvYFr1+pi9ZUb1wgSPCHp9bN1XR/9RybzirU=; b=lQoFJXJYV96SxAz7QiICSFfBUCLKRt2nKP0kCEdPR/4ugrRYkjwkTxhXkRvHtiw0Dn jtra1ZDpa/+ZSTy6ZpnzirxJEHFlwvigIU17PGeScvjlnwWbUQaD0hkOzQeZAMEToqot B3+4vlaYNI592hKU8TQikjRep+wELnCxjQFvsf/zc7zacci4cf++3hxpDj0Wh7DkPlMl 4ROtTBxg63X06oppedp2qd3KE8wjExsD82tVV50xj55rYW5GE21ab1WUv+K6iqNuj9Tt 2T1p4+tmqFwXMfqgiMC1RgEEixiSU1VNrEa9BindVbH4mhjPcQXs8jM4roY9JO11cH3d f2KQ== X-Gm-Message-State: AOAM533/6iBY8z6h1s5SWy+7KLkeDp/xCfCbjHt2L0yl9vnJ9oUP1igR VrnT6/GcaJ2KPwLqyWP/4c7crASOj6Dg8fTSc2fg5QBOYvr3gw4z6CYG1FezoYS+/w3AkYhuJyw GffkBDIYddXiK/eA= X-Received: by 2002:a5d:6ac7:: with SMTP id u7mr14069865wrw.25.1593887441612; Sat, 04 Jul 2020 11:30:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWLK5WP2QkFfs8TqG70mHqiHLQgxoVCgQFj1aK2YTNjshYf9P+v5SP0YbYMwg1ugPEjj6UAw== X-Received: by 2002:a5d:6ac7:: with SMTP id u7mr14069854wrw.25.1593887441461; Sat, 04 Jul 2020 11:30:41 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 29/41] vhost_net: use the function qemu_get_peer Message-ID: <20200704182750.1088103-30-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu user the qemu_get_peer to replace the old process Signed-off-by: Cindy Lu Reviewed-by: Laurent Vivier Message-Id: <20200701145538.22333-3-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/net/vhost_net.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6b82803fa7..4096d64aaf 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -306,7 +306,9 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(dev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + struct vhost_net *net; int r, e, i; + NetClientState *peer; =20 if (!k->set_guest_notifiers) { error_report("binding does not support guest notifiers"); @@ -314,9 +316,9 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, } =20 for (i =3D 0; i < total_queues; i++) { - struct vhost_net *net; =20 - net =3D get_vhost_net(ncs[i].peer); + peer =3D qemu_get_peer(ncs, i); + net =3D get_vhost_net(peer); vhost_net_set_vq_index(net, i * 2); =20 /* Suppress the masking guest notifiers on vhost user @@ -335,15 +337,16 @@ int vhost_net_start(VirtIODevice *dev, NetClientState= *ncs, } =20 for (i =3D 0; i < total_queues; i++) { - r =3D vhost_net_start_one(get_vhost_net(ncs[i].peer), dev); + peer =3D qemu_get_peer(ncs, i); + r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 if (r < 0) { goto err_start; } =20 - if (ncs[i].peer->vring_enable) { + if (peer->vring_enable) { /* restore vring enable state */ - r =3D vhost_set_vring_enable(ncs[i].peer, ncs[i].peer->vring_e= nable); + r =3D vhost_set_vring_enable(peer, peer->vring_enable); =20 if (r < 0) { goto err_start; @@ -355,7 +358,8 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, =20 err_start: while (--i >=3D 0) { - vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); + peer =3D qemu_get_peer(ncs , i); + vhost_net_stop_one(get_vhost_net(peer), dev); } e =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, false); if (e < 0) { --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888495; cv=none; d=zohomail.com; s=zohoarc; b=khTMy5Acn5Rh2kHanxAhWmfVQLTZkqMDwmhjfNyUxjR4ygBU6oUeZuVZDiGFdR4R4QsGEbW2/HF8Qvt2Q6ExASD0aq6b4e1MitghnG356C0AOSmTWz2EJGIhdBJZ+F5FIHHTRdne5eOssd5JeR3eTTkU2nTtX1Arl2NNDlRZkoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888495; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p8xQzlc8evAUo7O9syva6ExL2iB8bosWtyuBg9IIFRI=; b=h2XSecKx14iWgQnJxDIAeX7XCgFbkxXLKL1xUg5ThkoC7U9Gr8T7O2CjQuJqmhGUEAaTUX4SUvB/ApZj3siRLzO0HlEN8lONPGemSJKsByUTHzhCzBkqcnEXF2jOBm0g+J3nLh8gYHc0CXDvx0rTczxuZRNhBMwjdlThNtJh6h4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888495095205.6857525146089; Sat, 4 Jul 2020 11:48:15 -0700 (PDT) Received: from localhost ([::1]:49840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnCv-0003zW-RV for importer@patchew.org; Sat, 04 Jul 2020 14:48:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmw7-0004e6-4d for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:51 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51167 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmw5-0001ec-J4 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:50 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-UXnnwfpYPKCIAsYCPoYmFw-1; Sat, 04 Jul 2020 14:30:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id i12so36236114wrx.11 for ; Sat, 04 Jul 2020 11:30:44 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id t15sm17561762wmj.14.2020.07.04.11.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p8xQzlc8evAUo7O9syva6ExL2iB8bosWtyuBg9IIFRI=; b=B6OFO5D+Vz/J/nlFOGx+WeGNinn0rw537Vynh7FolU2eC7V2dfE/gC8HU2JzAhu4/Y0vPm WIgh5JVx3QqrVI7pPls8eCiYAmkcgG/rz4dBcAkydKSgt7aTIqlVL95/h0aH9GGJ2jWBRa KvsPEPoDBAws7djAWpEG6rdmyrS2yZk= X-MC-Unique: UXnnwfpYPKCIAsYCPoYmFw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=p8xQzlc8evAUo7O9syva6ExL2iB8bosWtyuBg9IIFRI=; b=VLPMoHn1Rda/dN9WSA8BeA3/Hd+855QkTnj/y8ZOaTfJ2nW4ESnEX9iAyUyOgd2fFZ X+RFhULbXx7r7NV/OQxvF2YvS1B2u/1LHmbPbH6uGAfKnM9vQw51mm4j3W8nHffai4uL sI/aauo03H+jkuqqmFfR87wjnuGkiUJQ657DXu4ERwsegW46p5ppXwN8P5q0HaXuvqRO /c/M0e1JxI1vo9o/OlD8DEAfj3kTXEhALXrR5ymAlZU3pxwycIj5v3ouuHaFaj2952/U LwexzTRIdjockgj41SM/HyCuPJ67O8a/uCkxM4pgAXW+jpD+RG0xkP0O05hZoU8co7ju x3hg== X-Gm-Message-State: AOAM530TcXjCXYo4oORQNnnmX5G3T4US06TKDVSRKDKo8zTeqSjXHbOm QS5iQaQ1+4+cD3gDZ2MDmyjpSFQxFd3reXtdpTuuGwSjATRBxisDetenA5XsXbVGuQWg5X9yek1 iuMwP2SjGdjowyLM= X-Received: by 2002:a5d:6846:: with SMTP id o6mr42103701wrw.370.1593887443873; Sat, 04 Jul 2020 11:30:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+3Ki+T9XV2NXUjwWV99TwYEajjX9+kfSLQN8tzLaLUOvMpv/1reoum1OlKvYxZmRSmpwhXA== X-Received: by 2002:a5d:6846:: with SMTP id o6mr42103691wrw.370.1593887443701; Sat, 04 Jul 2020 11:30:43 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 30/41] virtio-bus: introduce queue_enabled method Message-ID: <20200704182750.1088103-31-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch introduces queue_enabled() method which allows the transport to implement its own way to report whether or not a queue is enabled. Signed-off-by: Jason Wang Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-4-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/virtio-bus.h | 4 ++++ hw/virtio/virtio.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h index 38c9399cd4..0f6f215925 100644 --- a/include/hw/virtio/virtio-bus.h +++ b/include/hw/virtio/virtio-bus.h @@ -83,6 +83,10 @@ typedef struct VirtioBusClass { */ int (*ioeventfd_assign)(DeviceState *d, EventNotifier *notifier, int n, bool assign); + /* + * Whether queue number n is enabled. + */ + bool (*queue_enabled)(DeviceState *d, int n); /* * Does the transport have variable vring alignment? * (ie can it ever call virtio_queue_set_align()?) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index cc9c9dc162..5bd2a2f621 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3286,6 +3286,12 @@ hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev= , int n) =20 bool virtio_queue_enabled(VirtIODevice *vdev, int n) { + BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + + if (k->queue_enabled) { + return k->queue_enabled(qbus->parent, n); + } return virtio_queue_get_desc_addr(vdev, n) !=3D 0; } =20 --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888576; cv=none; d=zohomail.com; s=zohoarc; b=eUOaJRbpUDlyxQi2tc3CNpLAppnE6zsW5vEO5JOAGtioSlhw97OU3n5veaC6USYob6lyrXj/RKWOgipe9dp5jOERHGvxgIjLOFb92lsMsz5aHO89XfkNWROu4wyVfzEKtrTYgFYafmZFCkWXxVL0JWw+p1AdrAJKDs244CuFwp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888576; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YKm01s4uoYNcg0A8gRDSfiSMGc6pTEcCI5zK0YNeAPM=; b=aJB8zSJmyLYsu3079fI1HcorojnbhuxsWc/V9hmV1XNJFvw73dDKaYIsLMTjwBQbYPTcEVKuSAMjVda+fzuXHYmavG8N3DYXtxicRQSkh1HLAMHvjom0o2/YJ0LkCHnEdCbdYcTNl82KpvHtrgJU/+TaaYK2uWk4qGZQPnHMDWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888576515151.17406161228337; Sat, 4 Jul 2020 11:49:36 -0700 (PDT) Received: from localhost ([::1]:58050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnEF-0007Tk-A6 for importer@patchew.org; Sat, 04 Jul 2020 14:49:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmw7-0004eY-GC for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:51 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41256 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmw5-0001ee-NG for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:51 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-4cJR3tM8OBWWin4zQhvisA-1; Sat, 04 Jul 2020 14:30:47 -0400 Received: by mail-wm1-f70.google.com with SMTP id e15so40108980wme.8 for ; Sat, 04 Jul 2020 11:30:47 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id a4sm18860735wrg.80.2020.07.04.11.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YKm01s4uoYNcg0A8gRDSfiSMGc6pTEcCI5zK0YNeAPM=; b=CEU3YGRnp+POqEe3IafXrpsoSqJwpHJPXFyQyvE4rQfA4of7RjcbcaMLwpe6EHSdt0+sqZ 4SKxERBIAcDxykdWZUmIvmksy49cJSEfzmj4uvXn6GIWpIpG54mOvGTFQryLy4IhNipcZ5 h7Pg24LpbB4jE3I8xhDknrCUr40nIHk= X-MC-Unique: 4cJR3tM8OBWWin4zQhvisA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YKm01s4uoYNcg0A8gRDSfiSMGc6pTEcCI5zK0YNeAPM=; b=fxyRYXXGM+nDbN1u32Nx8bvD+goctoeC4pGmjS/6JHVHXcybSBSWu91BpvqdWIlPlF xn5rogROSVjlkQbbJRkvCX5AhodYUWHuBj1Lu9WaNBAW6l5blR27GeB//IZJkmp8O4G0 ztFeYjZCefeZzlZSAABbGe8rLoEzKvBFK8yisJ73cljuYADU2N87wBp4g8QoE2+dX+0Y YMhMQ51OEBK6HdC+OlO02ydV4qfeIxz8SaEDFcHgF/wHaZcp7eM18PM4Yp5PFNTrqQJX tu3w8WNABxxnCqNWP4G+eGXuhMpeUehynY3lncngpVFA7qcsZB7sf39awCZXILS0Blsv s/tg== X-Gm-Message-State: AOAM531EhwCUklB8mQHqSHi6XHThsFClcCLuUQrhUA5OBA5njP/tDNxx 3UXHCjkZ5GjCf++j9qSUtXE3ciAQmzFI3xw+DxsIsTh07GbpmOL0ffzqik83CHG1XFWjRIl76Rh 5DlHott4C9J5wKbs= X-Received: by 2002:a1c:5459:: with SMTP id p25mr40481905wmi.148.1593887446266; Sat, 04 Jul 2020 11:30:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdJFFcurFv26+J+uBSmjWpKFT7XWXKjPBqYC57snZPoA2Zwth4gkWFB2oXn7Hlh98f9zuwFg== X-Received: by 2002:a1c:5459:: with SMTP id p25mr40481897wmi.148.1593887446072; Sat, 04 Jul 2020 11:30:46 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 31/41] virtio-pci: implement queue_enabled method Message-ID: <20200704182750.1088103-32-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang With version 1, we can detect whether a queue is enabled via queue_enabled. Signed-off-by: Jason Wang Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-5-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/virtio/virtio-pci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7bc8c1c056..8554cf2a03 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1107,6 +1107,18 @@ static AddressSpace *virtio_pci_get_dma_as(DeviceSta= te *d) return pci_get_address_space(dev); } =20 +static bool virtio_pci_queue_enabled(DeviceState *d, int n) +{ + VirtIOPCIProxy *proxy =3D VIRTIO_PCI(d); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + return proxy->vqs[vdev->queue_sel].enabled; + } + + return virtio_queue_enabled(vdev, n); +} + static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, struct virtio_pci_cap *cap) { @@ -2064,6 +2076,7 @@ static void virtio_pci_bus_class_init(ObjectClass *kl= ass, void *data) k->ioeventfd_enabled =3D virtio_pci_ioeventfd_enabled; k->ioeventfd_assign =3D virtio_pci_ioeventfd_assign; k->get_dma_as =3D virtio_pci_get_dma_as; + k->queue_enabled =3D virtio_pci_queue_enabled; } =20 static const TypeInfo virtio_pci_bus_info =3D { --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888144; cv=none; d=zohomail.com; s=zohoarc; b=TldSZHUAY1v4HtdOAGAqJY9IgGQDjsewQK1j+NCR4NPC6qBNe9yJ/9f7uq5yaCMGolv2Kjw23r3bW8AwSZxG8RcyQtNXiQVH0s+gJxvERNl/RBldmHxQkEXzjjkGYTocokZtALPpVAv0F4c9ZWpq0DdpUCYNxk9oRmu3w5/v6LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888144; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tXbtGjuArFU0L6axuc9oufytf20N/xVITacNIR/IrnQ=; b=AtkJN/Sn2+Gj3e8EPjeEghB7Y1PE4dRF9GVDq6grINytfUTlrTz43eCq2ppUvaHAVXddfKc7YNUmOG2k2ImEzrqWti9cyOVfjGrt2DRs/gX1R0oJjat6fwPz19ECub8MZQ674rgJXbDArciQWChhbUuvx3Ir8CTaZl1ZgND5P/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888144019159.56220656443554; Sat, 4 Jul 2020 11:42:24 -0700 (PDT) Received: from localhost ([::1]:46584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn7G-0007f0-Bl for importer@patchew.org; Sat, 04 Jul 2020 14:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwA-0004kt-6H for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34437 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmw8-0001fy-Ec for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:53 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-kscUJR0WPdyyLSGoAdDuhQ-1; Sat, 04 Jul 2020 14:30:50 -0400 Received: by mail-wm1-f70.google.com with SMTP id b13so38188537wme.9 for ; Sat, 04 Jul 2020 11:30:49 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id q5sm8115508wrp.60.2020.07.04.11.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tXbtGjuArFU0L6axuc9oufytf20N/xVITacNIR/IrnQ=; b=RoUKcmhsRME2O4bQGE91dEOBu0dtnB1X6ppyzUjpqSbwBskFBxGyNZBe6RmvNJEQZwsG/C 2plvaR42ehBN7yQW7+THzZEic4n6UMjAxm6xVDT0uFKlzyJfRNMhC6OxImpz/fNjxnZ2RH xUAf0nATo1xThFZ1nxCeaGQmmQRv0tI= X-MC-Unique: kscUJR0WPdyyLSGoAdDuhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tXbtGjuArFU0L6axuc9oufytf20N/xVITacNIR/IrnQ=; b=luv+J1hUyPwGEr2QQArNyxQE/tKd6vsuWFbSXWqnBM2/X7A8C+pTWhhI3GmmiThsni kL013wVN05bm9BAIzVgINXiRaSlWbuu8/SbvcUSsC8EatR+DkJV68rp7XMO8QUzekIO5 y/WuNS8oB8bSGzT/7u8BiAgTsTVwRmlYmdC1zd6RuGUwJX33klKLCYLqJYz9m5wPU6V4 YNoEBv68badf0YCdGdHmFGUbBochmOjamZ1UfqcNVxzaZD8H6hUyAvaAhwm4M5ZQ83u/ YF1VizybDbxnpshbLoJu5d2SCUXpV3bgl8B5EvlGdnFV3VIbKr37Pw49MVT45E6Bh+YF Cp5w== X-Gm-Message-State: AOAM5319z2Ir/x+6/m6yEI0TcfZXbp3BSX26mtRetdfG/9FaIqwGjOhp kX0FkF9r7ZXaU6a/Qlq5uVU+e8uB734ufw+nF+ZCdj5Hv7saLdr48ZUFGDswdDdI/OYcrdkEqWz JaBAK6uzh/4LfB/c= X-Received: by 2002:a1c:9d07:: with SMTP id g7mr41976162wme.160.1593887448647; Sat, 04 Jul 2020 11:30:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBuKGuxEfeLC/H05GRf+YECK74aXaYEnnZhF3ewyvZp9MlDzVRN9tfs2+FSdSz14sfgSFA4A== X-Received: by 2002:a1c:9d07:: with SMTP id g7mr41976153wme.160.1593887448518; Sat, 04 Jul 2020 11:30:48 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 32/41] vhost: check the existence of vhost_set_iotlb_callback Message-ID: <20200704182750.1088103-33-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang Add the check of vhost_set_iotlb_callback before calling Signed-off-by: Jason Wang Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-6-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/virtio/vhost.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 5fd25fe520..10304b583e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1686,8 +1686,9 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) } } =20 - if (vhost_dev_has_iommu(hdev)) { - hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true); + if (vhost_dev_has_iommu(hdev) && + hdev->vhost_ops->vhost_set_iotlb_callback) { + hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true); =20 /* Update used ring information for IOTLB to work correctly, * vhost-kernel code requires for this.*/ @@ -1730,7 +1731,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) } =20 if (vhost_dev_has_iommu(hdev)) { - hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false); + if (hdev->vhost_ops->vhost_set_iotlb_callback) { + hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false); + } memory_listener_unregister(&hdev->iommu_listener); } vhost_log_put(hdev, true); --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888208; cv=none; d=zohomail.com; s=zohoarc; b=itzMvuufqfoEbIa7iIpsE3QiIGBorYz4DSif1mu6byNho+Ca66eni7+sfpjXylQfGgXjJbdF48vDRvCFq/hws36Ghs48QD6hAAs3KZ/g8bJ44tqYLa/K+YswY1f5EEsHQAEj9p32aovRlVk6KrvxYraKrxoj2wqzs5RYrT++4ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888208; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YYDftXcBQrqsgbkpJ5iu6MhYnQVu4atwyoFfOVtYo8s=; b=aB1dB1NOxpBpamQVDc5sM9f2iR1R1ykvCNX/G8ioq4z1rRlG02le2TZH29ONNC9xVrlvQafnn/dvwuqMQ9edE1utl0ky4JduIuFzF4z7Y1J7FwzKhDq6LQ5zwTpN1TSlBIPHAL6rd6egzXW+pUEbYegrSy4ue8MFxbiUqv/3aNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888208326827.1871871398782; Sat, 4 Jul 2020 11:43:28 -0700 (PDT) Received: from localhost ([::1]:52824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn8J-0001jT-3Y for importer@patchew.org; Sat, 04 Jul 2020 14:43:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwC-0004pg-DK for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:56 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52803 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwA-0001gI-PH for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:56 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-ErJfnVj8OHG84cYCtRcQgA-1; Sat, 04 Jul 2020 14:30:52 -0400 Received: by mail-wr1-f69.google.com with SMTP id y13so36374361wrp.13 for ; Sat, 04 Jul 2020 11:30:52 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id y77sm7176284wmd.36.2020.07.04.11.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YYDftXcBQrqsgbkpJ5iu6MhYnQVu4atwyoFfOVtYo8s=; b=cEjwfFePD/j2dB6/fBeSombGns3Q0yhP3U0jQwT31PkEZcCTfaxs2WRaJdohrjJSyCYQo0 uYkNqYtTT431eHJqXxeRfq43jxRcFkxNEZA8dIKAfgNt2lerFC3ytEpM/nAmibDGeWGsGK OkMe35sqWgWbDi5B/Su0r03GYTB76hk= X-MC-Unique: ErJfnVj8OHG84cYCtRcQgA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YYDftXcBQrqsgbkpJ5iu6MhYnQVu4atwyoFfOVtYo8s=; b=ieLq9vmrtnjQBEKjB5IR/V0WUYTXu8j2oeGZG+4DjarZRYU65l0zwtkWAIrzLoA5u1 P/ns0Vz0UEcU++WDYRUzgbZfg95Yc2fTeAVJNPE5sp+XF4cq6BikLgtfREa2J2nNbZUu v20eE3O5YNKoAGby+TS7EHKfVSXSnlSGkrw32XF4mmZSInGm5ghN544SttXeReQ/nO4Z yJlgTU9eQNYseMGFdYgO0JFgAw+7BSgHxpSdFRrwJg6AuYo0Pn8arP/tVr/L7pkvbkwf URp/VYxgLfiBllzaTBlj2ctdAq7o7RIxq7Oa6u8i/l4oR47WOhl/E9aAm2MHQBwu3Zdf 8tSA== X-Gm-Message-State: AOAM532niuD3EYPYLXdvKjfpDPX+X8priWEzgMbOQukhKbdzhRez05kw Z8z1h5lVPZa5kWat6xJIeN/83SngbRtfykW0HM352FfWGVms3DM4hcU2KaXdp2m7Yy8jG15H0Rg oc8LL3PqXNEr/45Y= X-Received: by 2002:a1c:29c6:: with SMTP id p189mr38530685wmp.70.1593887451071; Sat, 04 Jul 2020 11:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEWruZyg5Ir5vuXKr7DhssaD6SH8GIaifOSnuAAXGN1CCkskJTSCjQoqMuy6MpOiu1D8RjkQ== X-Received: by 2002:a1c:29c6:: with SMTP id p189mr38530674wmp.70.1593887450876; Sat, 04 Jul 2020 11:30:50 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 33/41] vhost: introduce new VhostOps vhost_dev_start Message-ID: <20200704182750.1088103-34-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch introduces new VhostOps vhost_dev_start callback which allows the vhost_net set the start/stop status to backend Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-7-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost-backend.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 6f6670783f..b80f344cd6 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -112,6 +112,7 @@ typedef int (*vhost_get_inflight_fd_op)(struct vhost_de= v *dev, typedef int (*vhost_set_inflight_fd_op)(struct vhost_dev *dev, struct vhost_inflight *inflight); =20 +typedef int (*vhost_dev_start_op)(struct vhost_dev *dev, bool started); typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -152,6 +153,7 @@ typedef struct VhostOps { vhost_backend_mem_section_filter_op vhost_backend_mem_section_filter; vhost_get_inflight_fd_op vhost_get_inflight_fd; vhost_set_inflight_fd_op vhost_set_inflight_fd; + vhost_dev_start_op vhost_dev_start; } VhostOps; =20 extern const VhostOps user_ops; --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888693; cv=none; d=zohomail.com; s=zohoarc; b=VLTDYtfbWRNM8VIoLA4ryP8uwKbld1FybbToDtkesncqPF28XAQDQAzswIlFd9iNAF4ofOaSnxojmSTlyRXSkc8Lagb3PeyGHLHYLeXdDCpa/ZOrGTl4kgUAnm00Z+GPQvk7usbYxDXhCouW4+vQKvbYiX2HB/r/dEG9VePcYEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888693; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WXw9VMdMEtGhEWjld76yv/MTPIVm1m5S/D9V6O7qby8=; b=Y2+T8WbRvNXp8CyX1Omyo62FvoszRg1m8imiHgaNmDvDc6WifGgot0rATrWelSM/tNZ1iU8H1TxijoQCT90YiJE5f8cpUPCHC7VfyjsoimxoG5xGeKykji0AhxCdAawDuhVjWrHqGZEvzA8sBbw1iUnZYx9l7knEO9Uin/OjZHQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888693203888.2046054301233; Sat, 4 Jul 2020 11:51:33 -0700 (PDT) Received: from localhost ([::1]:38292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnG7-0002ZB-U1 for importer@patchew.org; Sat, 04 Jul 2020 14:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwE-0004vx-Qw for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60639 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwD-0001h8-7W for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:30:58 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-z9rkV1D2MJyCFKIe41snOw-1; Sat, 04 Jul 2020 14:30:54 -0400 Received: by mail-wm1-f71.google.com with SMTP id y204so29100986wmd.2 for ; Sat, 04 Jul 2020 11:30:54 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 59sm18305862wrj.37.2020.07.04.11.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WXw9VMdMEtGhEWjld76yv/MTPIVm1m5S/D9V6O7qby8=; b=OLotX1VlwcbUqIlvLOm4HJfP1x5X/D0V3URNcUOZhvExRwLiP/+V7mWuOfpOfJPkh+uZht FKr/5TkoLnXRTmOztJlDMVW0gwxT7eeKZdMoJYe6bZ6cXi328UWtD6lrn4TP+KGewSjJqS DeqYxYUd3Vs2+HgxK8KQUSmbGUjhCQY= X-MC-Unique: z9rkV1D2MJyCFKIe41snOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WXw9VMdMEtGhEWjld76yv/MTPIVm1m5S/D9V6O7qby8=; b=RVk0U0ttbbiomHaM2RjilZZpmub2U+kUKRfXyoaaO2nZm89yyxY73oeXWSkTe/u2aw UztkMEuBEw1V6t9z7vVzYjwWQ9w/8mV1T85UedBDn+C4wA8IQ6vZvSIGWO4tKGgTEOna opMZTcvfR1WfIRyU11m8bC+1M1+znAvSRm49EwnVRcgZ36ZayHFYFbo31zQx2FPgGYue wWIKIQ7Ztb1Nd6ldMquE2ZqH2T0xhPI79Hh6DcmLoRfexToWtvM/FmRJmY7n1FG+soex neYalGUUX0VlL0pRx/7zl8dwwsNALu7i2TfGpjZCzU9RRP0AVgKzqInzPkP/NwCeeRGt MKPA== X-Gm-Message-State: AOAM530E1IxD9kfDW65w7FiGANFyY7SBJr9GWghE1ysuN+Cv/D1+yQif fIf6PfjbQxiyUBn0VhAQOJd4+xUJ6+EPbIQY/vEGFXtcMfhekgpQa1IWW+fBkzT2RV1DiKRzLjz rrvkzkGyYnJCRR7Y= X-Received: by 2002:adf:f452:: with SMTP id f18mr41472711wrp.78.1593887453450; Sat, 04 Jul 2020 11:30:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMUUkKR2FR/4a/FOgvRSi3jH3V1HWgotgH50pe/qlYlknuFEqkGC3qbeUc9NAUvfNoYt1n9Q== X-Received: by 2002:adf:f452:: with SMTP id f18mr41472699wrp.78.1593887453252; Sat, 04 Jul 2020 11:30:53 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 34/41] vhost: implement vhost_dev_start method Message-ID: <20200704182750.1088103-35-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu use the vhost_dev_start callback to send the status to backend Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-8-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/virtio/vhost.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 10304b583e..32809e54b5 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1685,7 +1685,12 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODe= vice *vdev) goto fail_log; } } - + if (hdev->vhost_ops->vhost_dev_start) { + r =3D hdev->vhost_ops->vhost_dev_start(hdev, true); + if (r) { + goto fail_log; + } + } if (vhost_dev_has_iommu(hdev) && hdev->vhost_ops->vhost_set_iotlb_callback) { hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true); @@ -1723,6 +1728,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + if (hdev->vhost_ops->vhost_dev_start) { + hdev->vhost_ops->vhost_dev_start(hdev, false); + } for (i =3D 0; i < hdev->nvqs; ++i) { vhost_virtqueue_stop(hdev, vdev, --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888303; cv=none; d=zohomail.com; s=zohoarc; b=SRicIIIddEue5EMFQqkR+dkfCIkSiTFxlxpyZIKaQXN7cqvJjT3/m/daFDIynmR92c6RR3lqckPnWKfYvMIa58RoN7a5ab9S2ZBCRwz0l9p073utLQU0BjPmjP7dpbpelo5kWi9zfgPEBfxoU9C/Ag8sXTriUKxUKB+vqlGMh1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888303; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h8govD67lanJJAmIgSTuxQeH9ZylAQ7cIEwKwJSkzkc=; b=Ku1yqW+DGQQ4dZEo2X38XkPwCX9OHZ655G+HL4T+/woNfO9k5zLHvbAUV97PJOCs0gJmlE4ENpnMsbr/qcG7gYv1mzk/sKLxB7+yA3XrzjxmYAU7wgcX1SOpKFM2y22MhQcQSB+8MkXE7IfsIMoFvlhcUSuoZt7fv9NsVJnJldA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888303985618.1531166322945; Sat, 4 Jul 2020 11:45:03 -0700 (PDT) Received: from localhost ([::1]:32936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn9q-0005HB-MZ for importer@patchew.org; Sat, 04 Jul 2020 14:45:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwH-000530-Tm for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48853 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwG-0001hH-7i for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:01 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-sMLozI-AMiygTSCdW7_JzA-1; Sat, 04 Jul 2020 14:30:57 -0400 Received: by mail-wr1-f71.google.com with SMTP id s16so23281627wrv.1 for ; Sat, 04 Jul 2020 11:30:57 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id r8sm17523480wrp.40.2020.07.04.11.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h8govD67lanJJAmIgSTuxQeH9ZylAQ7cIEwKwJSkzkc=; b=NwclBJungDvBflgY6ZA7zM5yFUntwpLH2u7mOGIaMFeYgrV2Tvz2oDdJA6yoGvQ3NYMPSv fdB1LF6SLY1FsFFfIfcFKhTzu85jpKN0BU8kkcnYWsZYZhY+6QmR9RVPOYB53Ilr7WJWlT oIwBEGAlJ/dZLW/83k1MZMItYtlISDI= X-MC-Unique: sMLozI-AMiygTSCdW7_JzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h8govD67lanJJAmIgSTuxQeH9ZylAQ7cIEwKwJSkzkc=; b=sVgjc8dQFmcgzNTZPx6tMyQ4lq52iYrEwfrO9BuXrcHuS3+O5NoX0eUubEfi4IpWWw U7zbElFpMEg2yVUp15YN7tJAvdgBJbaR6TJEUyTP2m8xuOGdOAgy+uS9K1jtNOyerATv dVgVVPNoAAlRrMQHHwEViSUTO10W/Y/aGKU5rHwP1KZkxjcmyoxbP1qaBo4+UGaX2J3w fEFI1Bx3ErXeMWSLyiiecz7F78cLAanan6dvPlf3ia3YZwDol2wjhYwUawVKhGdqx+Hj siRg4jExFa0ylGgauoP+dclkcm1yM4MjNEcxJdPjtV8yogoBDVGSg3m6Ptm+rT8Ym1Qk Nw6w== X-Gm-Message-State: AOAM532SJSZopriiQdpdMYgH7MIv7xO9Y+8EIySAP5oreMGKeTHt9RDJ L3CYd814dKOwRCyiYQzdgK/wSUZULpSkFBY7hw0Jb4PMp0Zi2fpEVSCUK8cPWbRA1GbsWvLTJdX eEtKyeCl8UK9496c= X-Received: by 2002:adf:ed4f:: with SMTP id u15mr40768083wro.318.1593887456093; Sat, 04 Jul 2020 11:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7o45bmOSP6iFycd0u9lYGGBcNJgMmsmANcbnppIhjuLucrWxib+DrU/VAyrzufzddRSdwtw== X-Received: by 2002:adf:ed4f:: with SMTP id u15mr40768078wro.318.1593887455964; Sat, 04 Jul 2020 11:30:55 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 35/41] vhost: introduce new VhostOps vhost_vq_get_addr Message-ID: <20200704182750.1088103-36-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch introduces new VhostOps vhost_vq_get_addr_op callback to get the vring addr from the backend Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-9-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost-backend.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index b80f344cd6..fa84abac97 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -34,6 +34,7 @@ struct vhost_vring_state; struct vhost_vring_addr; struct vhost_scsi_target; struct vhost_iotlb_msg; +struct vhost_virtqueue; =20 typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque); typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); @@ -113,6 +114,10 @@ typedef int (*vhost_set_inflight_fd_op)(struct vhost_d= ev *dev, struct vhost_inflight *inflight); =20 typedef int (*vhost_dev_start_op)(struct vhost_dev *dev, bool started); + +typedef int (*vhost_vq_get_addr_op)(struct vhost_dev *dev, + struct vhost_vring_addr *addr, + struct vhost_virtqueue *vq); typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -154,6 +159,7 @@ typedef struct VhostOps { vhost_get_inflight_fd_op vhost_get_inflight_fd; vhost_set_inflight_fd_op vhost_set_inflight_fd; vhost_dev_start_op vhost_dev_start; + vhost_vq_get_addr_op vhost_vq_get_addr; } VhostOps; =20 extern const VhostOps user_ops; --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888229; cv=none; d=zohomail.com; s=zohoarc; b=IfqB7eFp093OkVlL9aZfMQ1jgbzcNWNe6ZrToaWosVPFY+MQLSGqNVe37IOgmWQfQpKCM7MPF6SI+kx0fC0ixB746GXeoAyM+BvQiMHN3q3OXhKW+/V48Ym+UlVW4wxZivTtwdGA5nRADXYP01KSBFGDeqewbauoR7hVFs/Xvh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888229; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3ExkqCYE+MZcrtgAoyxaOOvh3MgXkaeP71bTYP6/+H0=; b=h46GFkxU9vCAnxRt03VMsUPmo6raT1F4hR0I18ESOBVnPkrIiGic1GGB1uzuL+EyEFd0CjGEDcwHs88WPhEvNtA/sjC8ztjfhZukYG5cRgN2eJavMIFK/ARsYMC6G0ZfPnUso76CLX1kMdCMvV16zN/arXxJHOOqJR/W6Tf5tAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888229252688.5440541289033; Sat, 4 Jul 2020 11:43:49 -0700 (PDT) Received: from localhost ([::1]:54900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrn8e-0002Yr-2A for importer@patchew.org; Sat, 04 Jul 2020 14:43:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwK-000589-8e for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40285 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwI-0001hc-FK for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:03 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-6Dh6bSz6N8Svkzqnd9HSxQ-1; Sat, 04 Jul 2020 14:31:00 -0400 Received: by mail-wm1-f69.google.com with SMTP id z11so40160250wmg.5 for ; Sat, 04 Jul 2020 11:30:59 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id v11sm54224641wmb.3.2020.07.04.11.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3ExkqCYE+MZcrtgAoyxaOOvh3MgXkaeP71bTYP6/+H0=; b=evCOB0cdPgO60WCkiW8HzHpq/hYceWzOkBGAp82PNzRFMPV6I63WzJILMZhT93SAHG4GXG u9PWtRe2kPEIDmMPtT+cumoFOPfhXabp7mlNMUFZh7l2/0xAR1zxOVT0K6jzBi6FUCubLS U3Jq7MEBQwj8ZLbMWpFOr4BVuIHlfsw= X-MC-Unique: 6Dh6bSz6N8Svkzqnd9HSxQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3ExkqCYE+MZcrtgAoyxaOOvh3MgXkaeP71bTYP6/+H0=; b=jGqgQmwA6Pw8Z1ln9VuiQt4jX7HTN5IxeMz6OoxX9pbnQVanf3QOzIR7tD3Cr5guY8 Ltm9CtF7BvSYnbK7Th7uK/HKHwBjJVooM/ym9P9dV3gCB5Hn5VxP8OfJDr3BDcqW0dJT blCH8DqV29bv4R0V4+qqcKS1nL6dIaIvZcfdUZFqXTX+I8avsCwnJwdXxfbpQTTBHH9Z 1ylIRV27nAyA+/PPfg+IKcp5+skbizBvCnsioYsGxs4Eo0oBovdy1x4tWE1RI2EHDXmQ pIalZOqDm6xvPWbfOrk+w+c1lHn1higmA0vUJrbL+kijMYI027tlUa13aB+y7wxoaI+D vS6w== X-Gm-Message-State: AOAM531/McHNFDKuFhm643qrhF9w5JJD6KOYw37LBfqQAMApXsk+Cnry Urki4MwLn+aR7GffQhz7Uk9PEuPvEKcc8AET8fXJanQNtCJmoqzzo6Fy2/y1nwFf43oZ0wssbg5 uJB/nCDiX1IVnyTo= X-Received: by 2002:adf:f60c:: with SMTP id t12mr44996601wrp.198.1593887458330; Sat, 04 Jul 2020 11:30:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTreTBt+rQeyH1JQJqPgS1oL5zFWDdXRhmi55K32zByg3AFpyyawPDOLXm6AfNfancG+IciA== X-Received: by 2002:adf:f60c:: with SMTP id t12mr44996594wrp.198.1593887458171; Sat, 04 Jul 2020 11:30:58 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 36/41] vhost: implement vhost_vq_get_addr method Message-ID: <20200704182750.1088103-37-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu use vhost_vq_get_addr callback to get the vq address from backend Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-10-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost-backend.h | 4 ++++ hw/virtio/vhost.c | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index fa84abac97..bfc24207e2 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -118,6 +118,9 @@ typedef int (*vhost_dev_start_op)(struct vhost_dev *dev= , bool started); typedef int (*vhost_vq_get_addr_op)(struct vhost_dev *dev, struct vhost_vring_addr *addr, struct vhost_virtqueue *vq); + +typedef int (*vhost_get_device_id_op)(struct vhost_dev *dev, uint32_t *dev= _id); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -160,6 +163,7 @@ typedef struct VhostOps { vhost_set_inflight_fd_op vhost_set_inflight_fd; vhost_dev_start_op vhost_dev_start; vhost_vq_get_addr_op vhost_vq_get_addr; + vhost_get_device_id_op vhost_get_device_id; } VhostOps; =20 extern const VhostOps user_ops; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 32809e54b5..1e083a8976 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -773,15 +773,25 @@ static int vhost_virtqueue_set_addr(struct vhost_dev = *dev, struct vhost_virtqueue *vq, unsigned idx, bool enable_log) { - struct vhost_vring_addr addr =3D { - .index =3D idx, - .desc_user_addr =3D (uint64_t)(unsigned long)vq->desc, - .avail_user_addr =3D (uint64_t)(unsigned long)vq->avail, - .used_user_addr =3D (uint64_t)(unsigned long)vq->used, - .log_guest_addr =3D vq->used_phys, - .flags =3D enable_log ? (1 << VHOST_VRING_F_LOG) : 0, - }; - int r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); + struct vhost_vring_addr addr; + int r; + memset(&addr, 0, sizeof(struct vhost_vring_addr)); + + if (dev->vhost_ops->vhost_vq_get_addr) { + r =3D dev->vhost_ops->vhost_vq_get_addr(dev, &addr, vq); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_vq_get_addr failed"); + return -errno; + } + } else { + addr.desc_user_addr =3D (uint64_t)(unsigned long)vq->desc; + addr.avail_user_addr =3D (uint64_t)(unsigned long)vq->avail; + addr.used_user_addr =3D (uint64_t)(unsigned long)vq->used; + } + addr.index =3D idx; + addr.log_guest_addr =3D vq->used_phys; + addr.flags =3D enable_log ? (1 << VHOST_VRING_F_LOG) : 0; + r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); if (r < 0) { VHOST_OPS_DEBUG("vhost_set_vring_addr failed"); return -errno; --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888406; cv=none; d=zohomail.com; s=zohoarc; b=cAiAMn/z7Y+2Ho5PI5jiTVjOS+9T2aRr+1lOYg1ZWMJBSa31LqVFH2jcIczknVi7s1GWmUP+xbcdN/N15fAtXwJwGV70S53V3B3bz0GCV4stq/5AANugWOgo8bfZ+IMDUZI2iOa588gbumqJlblSLGYSBBUbY4777wgfv8FmY78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888406; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zxsZyEl0Ic2zeqGPCHFNr5fX901vp9gn578GtCCySkg=; b=UdAp0JH6HU3iOYCOMy8A3It7Pd8flguA+lJvIXg3EqqpFfcmZbVeoZtvR5oXfvKVMzn0pYxMjggSeLNZ5D8P8Q0S7ewiQiXl7P8aoEfGpl2J3ZuCz0hSINq5ITpRoJSf+8vsNI8awVlvdKABWeRAQX1nGOPjfDs7dOvlXUkpfCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888406265199.38646731989115; Sat, 4 Jul 2020 11:46:46 -0700 (PDT) Received: from localhost ([::1]:41282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnBU-0000Fk-Va for importer@patchew.org; Sat, 04 Jul 2020 14:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwM-0005CV-FA for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:06 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:55272 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwK-0001hp-Ql for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:06 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-T_oxx4DBNsCNOUrys1a_RQ-1; Sat, 04 Jul 2020 14:31:02 -0400 Received: by mail-wm1-f71.google.com with SMTP id o13so40189995wmh.9 for ; Sat, 04 Jul 2020 11:31:01 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id 68sm17479697wmz.40.2020.07.04.11.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zxsZyEl0Ic2zeqGPCHFNr5fX901vp9gn578GtCCySkg=; b=cOcqpmq6a+/cCzu4qfGOk59R620AVwjUD7d6DbXUsX1AmEZxBhITJdQ/YwBV06oojnmhEl xpAnShfqfS4/9PylAP9XcOoRDhKvmOUBdUz0tclqhFoJ5wrKnITCHVz137z5EAl1Om8neG VTa+9TW1y22pWhWQBRZS38bRGkNoZJY= X-MC-Unique: T_oxx4DBNsCNOUrys1a_RQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zxsZyEl0Ic2zeqGPCHFNr5fX901vp9gn578GtCCySkg=; b=JLnabfiSqcCQX0n6mYtRWLWMQivqRvei9i64OoHBZzvunnXs3D3lvMPk+2O8T7wdvj JTWOowH5+x4y3+XlmET7BZPqdYuYEFwGykmuNhL8BCP5TrgULsbfMm2SHcb8cjqDC16O mHkjgGGhHU+RbRUMjGREev+FwtWj/Vevf4j5miGcM/qlxrxveQdKXbOnqgTicGnNPE9n GtNiczRvYCKo3Zh11qAnccqYUPk2bH/LoNRCtCFUAyMQEFptvS9MdN/uTtMnAasp8kpK gW6pDQd0yxL5buHsjkFBulcEy9uO3XmTcZDhgdgMhMnhV9BRIeG9qAodgn5SJS8xm9Yj LwOw== X-Gm-Message-State: AOAM531xua1Tmtm9xUai+IgNdpNa6cENKCWx9aAg/MOYUaQrLReQ/qw1 aCTxYjDD8ZwvHGxOUqvSYqQJ5JcanFCgQVt2rnSeL2dZVsWyKj08eUkxmboVa7mLjTMwc6M6rMp /aKf1xyFzUUjOLbM= X-Received: by 2002:a5d:6b8c:: with SMTP id n12mr42148509wrx.352.1593887460671; Sat, 04 Jul 2020 11:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu4j4NZqOoPOYexPsdJ/qusDiClakwVkxT1uLaeahCIfg+cNTjhrzmLBJTBx+46lyfkluqkw== X-Received: by 2002:a5d:6b8c:: with SMTP id n12mr42148505wrx.352.1593887460527; Sat, 04 Jul 2020 11:31:00 -0700 (PDT) Date: Sat, 4 Jul 2020 14:30:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 37/41] vhost: introduce new VhostOps vhost_force_iommu Message-ID: <20200704182750.1088103-38-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch introduces new VhostOps vhost_force_iommu callback to force enable features bit VIRTIO_F_IOMMU_PLATFORM. Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-11-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost-backend.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index bfc24207e2..e7cb8d028c 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -121,6 +121,8 @@ typedef int (*vhost_vq_get_addr_op)(struct vhost_dev *d= ev, =20 typedef int (*vhost_get_device_id_op)(struct vhost_dev *dev, uint32_t *dev= _id); =20 +typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -164,6 +166,7 @@ typedef struct VhostOps { vhost_dev_start_op vhost_dev_start; vhost_vq_get_addr_op vhost_vq_get_addr; vhost_get_device_id_op vhost_get_device_id; + vhost_force_iommu_op vhost_force_iommu; } VhostOps; =20 extern const VhostOps user_ops; --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888336; cv=none; d=zohomail.com; s=zohoarc; b=BQy3g0CbbFej/6+AzhACd9+xxZBEcw86n8k8ZvGHST2AlSCBMzCGPV9hVjfxebjJkzabi3Rdfu0Ga/uDSX0CGBE1MogLSjqZi+ExCyoq8C+BP9kfSnmSlbYVf6CMZlGML//Odi399vZuddBvWaqmRlufb20pcKTZIQbw/eQPWaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888336; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bXQcnI6PvYNrc0EdCBus9d90Kc/4/S8iNwGC64RK2O8=; b=d2+MSxO6sTid/rBmpI2pTl6DH87aGOt4IE1+FGdMDQXJ0NWGVNisSi41/qKKm2Egec4RTrUBjKmDDwIIIe0PkCYgbmwtYXwaQLv7tWLuWSDgbDdacmnumzH+MZq8wBPpzgn9b3W5TEtT8V7r3ZGPMxc+kwozD479+q3dcDXCLGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888336228682.178755729017; Sat, 4 Jul 2020 11:45:36 -0700 (PDT) Received: from localhost ([::1]:35168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnAM-0006AH-VI for importer@patchew.org; Sat, 04 Jul 2020 14:45:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwR-0005Nl-TM for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47218 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwQ-0001iG-0G for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:11 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-TQuGDHkIPA2ACPiEORkUFA-1; Sat, 04 Jul 2020 14:31:04 -0400 Received: by mail-wr1-f70.google.com with SMTP id b14so36495575wrp.0 for ; Sat, 04 Jul 2020 11:31:04 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id u8sm17007683wrt.28.2020.07.04.11.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bXQcnI6PvYNrc0EdCBus9d90Kc/4/S8iNwGC64RK2O8=; b=DqsPYe1pGOWsxNUlZTDqpfhKfgg0LLFvRX5aXHgpXSqAGAJLffJs/07QrQt7/zYjILPeop kquk4RsTqnaD3S5mqcqbgMjtZ8BSetTnkFOy1/x5rGMeECFBJif2pRfwCms5ozdDUVQime /bp6yaOL9lEDNx5G7kq+2Kt55ugK/7A= X-MC-Unique: TQuGDHkIPA2ACPiEORkUFA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bXQcnI6PvYNrc0EdCBus9d90Kc/4/S8iNwGC64RK2O8=; b=V9626T96YR6r/CbrPNvh5uLzOnuBoVlzlMlwDrSe2EWMAviWLG3BweP8KQWJVIpU5/ RUHenAlgEpkwXJD6kR1Q/JeWZPXVHSvlceR1QLSF/ueUYMIt8I9xXuYBqWL//ZTpYt8V Wpg99VfR1tcGiZ2wOvxCXJCbamW0qDdftUfqsliq5DIR/EoDOVrJ5rX6lENoVkZC1lAz isk4Fl0OLvph3R8JaqYYCS1FaZMr1VrZn5DCwAxXVpZWZTQsRTBKQfGodTMu3wtdTZhu 2e9YYcfH6SrQ7XJRq5BpEXXy35NNHy48ZhJhUS09xH5XroGWWzV0TiiQIER2G+4uHvQ7 c3sg== X-Gm-Message-State: AOAM532mkRIJoqxCqmfA0K1rRAnqo0WpChWAR+M0zeYFNkvnBtWQntQJ CtQfj7Z7tk+CA7f/GHWjQfivuJWwUGsnmGueob0AlDa0L/4dvSY69LrPVn/8JYUf2zPHneYZuNg x1i4hW13S9K5pM5o= X-Received: by 2002:a5d:6912:: with SMTP id t18mr41081832wru.411.1593887462976; Sat, 04 Jul 2020 11:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu/tTGeWJsYhj0Mcg34Kyyo5pdZZFzN1ONJp3PYv0w110/HS05zTw3svSK1EkwmbP5ZFIjxg== X-Received: by 2002:a5d:6912:: with SMTP id t18mr41081828wru.411.1593887462840; Sat, 04 Jul 2020 11:31:02 -0700 (PDT) Date: Sat, 4 Jul 2020 14:31:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 38/41] vhost: implement vhost_force_iommu method Message-ID: <20200704182750.1088103-39-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu use the vhost_force_iommu callback to force enable feature bit VIRTIO_F_IOM= MU_PLATFORM Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-12-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/virtio/vhost.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1e083a8976..1a1384e7a6 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -810,6 +810,11 @@ static int vhost_dev_set_features(struct vhost_dev *de= v, if (!vhost_dev_has_iommu(dev)) { features &=3D ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM); } + if (dev->vhost_ops->vhost_force_iommu) { + if (dev->vhost_ops->vhost_force_iommu(dev) =3D=3D true) { + features |=3D 0x1ULL << VIRTIO_F_IOMMU_PLATFORM; + } + } r =3D dev->vhost_ops->vhost_set_features(dev, features); if (r < 0) { VHOST_OPS_DEBUG("vhost_set_features failed"); --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888556; cv=none; d=zohomail.com; s=zohoarc; b=bJP7Y+Kxx9qveOx3ZsZut2LsUzZ0JH8x4jHULZyBXorf0PfgwCSvvmKbAiRZ/2xO3X5eSvqaZj5bVh3KviWywqze5yDwaIc7wesUk6VadX0HOVblEbUvyi5jmgiFy34CFKYiplI2MdMFU+Wtkmwb9fddN2TACk8Oj/w8eDiWGS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888556; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lL5Gr+1OC50JlOP4HvsRLOyw+1DMZM80TfKgTML516o=; b=W7prCuG4dwKr/4Uh/3OUkIDfCQOLlg0mJKlPbfShdkdMrnUpSjqbS9/8PYB1HTTFr2KcpSm9EgsUvGBhrDdybNovBK9CSlVpTNVP/bFQoDFvYrnr/vRe0d+K897VjfFUI2iAObXRpM0pd7QYG+92i/Q86/EpdQkc8PfosIcQlZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888556278515.9328335721282; Sat, 4 Jul 2020 11:49:16 -0700 (PDT) Received: from localhost ([::1]:56050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnDv-0006gM-0F for importer@patchew.org; Sat, 04 Jul 2020 14:49:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwR-0005MO-5g for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32779 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwP-0001iA-CO for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:10 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-hW50DHe9PqmHZvVTkykwDQ-1; Sat, 04 Jul 2020 14:31:07 -0400 Received: by mail-wr1-f69.google.com with SMTP id i14so36214933wru.17 for ; Sat, 04 Jul 2020 11:31:06 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id l8sm17584576wrq.15.2020.07.04.11.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lL5Gr+1OC50JlOP4HvsRLOyw+1DMZM80TfKgTML516o=; b=faASex5y1IkQ+1T47uycmGzTt7AuFFshjy/Ioo3XBLy6hU+ANBf3CbHQ/uOK30+WpimoJI Y6SUKjOVmFtcAiqPlUAwHInpXjKJbDO5l6wtIIJwf/kKnapseIH2dK7mpbYL+v6NDme6x6 XGEUgA50YN1r7/MDnEz+HpEsqQbP1p4= X-MC-Unique: hW50DHe9PqmHZvVTkykwDQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lL5Gr+1OC50JlOP4HvsRLOyw+1DMZM80TfKgTML516o=; b=evDOBrxmf6ZFWdqAcepeXS89CshVQiVHr3T4w/QLaQ1xAewUsxLFzRNBvjtuc4G9z0 miQuFC7RPdZ+3aUv+c/iDcB03lRqPlTXIXjWTmLKlvP4bqs+pv+9LE63wBwmlrjDRq6C JWAgqXv9gDBYqySFnmAPa7miHyPckYacOIJE1olHOsWIBZas/oBwtGHIHdOeLrl0KfXZ Y9GYa8e08k2TxNYhswITlpktBZZCURl6sZkd09/+0fwHOXC1o8bJ8Fg3w/W+W0E+nsIl zOpnuU5auYuF24dZ8chr9UXzUpCfkaAc+IeM/KnCuYCAh1fpZpmLeQUBaqnzQveNgw3x a2dw== X-Gm-Message-State: AOAM530KYMwawC4ld497SuGQjEU1l/nCbbGlkpq8fHOuxDQYgNUNtUoK sale5gCRkSKRBPq9xhgYoxZb1o1zhauR8JfcVSJSeSUUBHx+NlTj5SwuGMtnKwp5lAiXM3GXdxA d4lITnMM88uQ67pE= X-Received: by 2002:a5d:6107:: with SMTP id v7mr40933419wrt.174.1593887465585; Sat, 04 Jul 2020 11:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCrXpnvhqKhed4ADQJx15gnkgjLh4Rl+pWt/g+5w9ESzNyfPvIvZFBbTGkMPmgUbNymEFPYA== X-Received: by 2002:a5d:6107:: with SMTP id v7mr40933406wrt.174.1593887465349; Sat, 04 Jul 2020 11:31:05 -0700 (PDT) Date: Sat, 4 Jul 2020 14:31:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 39/41] vhost_net: introduce set_config & get_config Message-ID: <20200704182750.1088103-40-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch introduces set_config & get_config method which allows vhost_net set/get the config to backend Signed-off-by: Cindy Lu Message-Id: <20200701145538.22333-13-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/net/vhost_net.h | 5 +++++ hw/net/vhost_net-stub.c | 11 +++++++++++ hw/net/vhost_net.c | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 77e47398c4..172b0051d8 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -28,6 +28,11 @@ void vhost_net_cleanup(VHostNetState *net); uint64_t vhost_net_get_features(VHostNetState *net, uint64_t features); void vhost_net_ack_features(VHostNetState *net, uint64_t features); =20 +int vhost_net_get_config(struct vhost_net *net, uint8_t *config, + uint32_t config_len); + +int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, + uint32_t offset, uint32_t size, uint32_t flags); bool vhost_net_virtqueue_pending(VHostNetState *net, int n); void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, int idx, bool mask); diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index aac0e98228..a7f4252630 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -52,6 +52,17 @@ uint64_t vhost_net_get_features(struct vhost_net *net, u= int64_t features) return features; } =20 +int vhost_net_get_config(struct vhost_net *net, uint8_t *config, + uint32_t config_len) +{ + return 0; +} +int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, + uint32_t offset, uint32_t size, uint32_t flags) +{ + return 0; +} + void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { } diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 4096d64aaf..4561665f6b 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -110,6 +110,16 @@ uint64_t vhost_net_get_features(struct vhost_net *net,= uint64_t features) return vhost_get_features(&net->dev, vhost_net_get_feature_bits(net), features); } +int vhost_net_get_config(struct vhost_net *net, uint8_t *config, + uint32_t config_len) +{ + return vhost_dev_get_config(&net->dev, config, config_len); +} +int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, + uint32_t offset, uint32_t size, uint32_t flags) +{ + return vhost_dev_set_config(&net->dev, data, offset, size, flags); +} =20 void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888495; cv=none; d=zohomail.com; s=zohoarc; b=m1feiEh+jCTrPKEY5yXaZykO8P+28nQa42y4FWRV2Oh7GrU1XQqSieB7MeUFaotVFiBiG0TlKJcmI1k2ZouLgLaCw/UMRzAgn+BM0mxypAukLPvnxUYch8geRvfR8rEuJ7Tlsy9043ws0HHzk3jnNtGwPQlM8TbYw9a8cZ9QUwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888495; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=35h53FwjSN3p5UKoC6P032Cw8Btt7gsrDUuQhYxn6E8=; b=BUjTdT2FIY4MP048OuZilJ3yQkEgreu9FmvNgXzB3dL1PSij4JYSArIR7I5hr5rtpLnIBFEhUipFqEe+PBFFu9iUuq3eiOJ29ZH09n4gVPdXqWxDMODEu65BGSxRCDJHR4/VX9Lhw2oEdv+bMCfzECrsxUSLxhkRJ6grjYDnET4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888495206854.429476244065; Sat, 4 Jul 2020 11:48:15 -0700 (PDT) Received: from localhost ([::1]:49784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnCv-0003yA-UJ for importer@patchew.org; Sat, 04 Jul 2020 14:48:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwW-0005Xv-Nr for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:16 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28898 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwT-0001ia-F0 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:16 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-a8e3RXYpOV6vT35xe3uERg-1; Sat, 04 Jul 2020 14:31:10 -0400 Received: by mail-wr1-f70.google.com with SMTP id y18so16761113wrq.4 for ; Sat, 04 Jul 2020 11:31:10 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id v12sm5234917wrt.31.2020.07.04.11.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=35h53FwjSN3p5UKoC6P032Cw8Btt7gsrDUuQhYxn6E8=; b=RWlykdPGLM7X9kYaoiocxGls8Jd5sJE/+vWOjUywQlRa+ISn2ID+k2e++PGCV7sfx0pTWg XK0aQ4Fc9KTVtTqCvD55rDQm0f7OZXZ+MEdCsAchpRWkfNnh2PPqVf/MU8ePE6+PCKH8t8 Lz7Lb8HIH/PqqnfNjqus99GCCXkjl9U= X-MC-Unique: a8e3RXYpOV6vT35xe3uERg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=35h53FwjSN3p5UKoC6P032Cw8Btt7gsrDUuQhYxn6E8=; b=phUoEVIvdIVbLapFQniqo/V05bG9ypMahtl96Tj2OOnIeFA3CM5EGbvzhcyz+AMGmj 3cWReLBBj+gWkWp1QtNfXdEl1U3gbvnvpuTjsXz/A+9L1RBJiDRY1YU4+eYa2hcL+lEa L5oKjbpGYdALEZyvvFd9946YDg+9Ys6U9N0qQ1Nl7fMMP+3A3WpH0xaD3/gcL39Ziyb0 3HjrZFb96Dujpxf6uimvos6vqo6qrc+06fw05POpfzXYTs2xfI0rKumUditM7U6Q8Fsz +2U9ziPYsU4qH1sifphcMkV1JU7h8TGXo80OBW45A89t8M/hqWj/7guHlsb9P3dU/FtS Ql5g== X-Gm-Message-State: AOAM533Pjx/hBB5XWov5wlGPY2uGTMFOxKWq6kUoPEAW+ocvlxIHNyHQ ygYjBh1SaAO/rdXgG5dMcy3STIrLqKe5UqFZBJcJcGtoRmXTmfybydMhutuyo2lTtfrhXILEcOj XjyYu8uyFQF9mYkk= X-Received: by 2002:adf:c551:: with SMTP id s17mr40288174wrf.330.1593887468560; Sat, 04 Jul 2020 11:31:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ6eit1QG3LF+cjXzcxzyunauqU3lrnRyFXDwp/Sv1NXx/+N28zqxh8Nic6tFGrHRDQQ+30w== X-Received: by 2002:adf:c551:: with SMTP id s17mr40288149wrf.330.1593887468014; Sat, 04 Jul 2020 11:31:08 -0700 (PDT) Date: Sat, 4 Jul 2020 14:31:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 40/41] vhost-vdpa: introduce vhost-vdpa backend Message-ID: <20200704182750.1088103-41-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Peter Maydell , Lingshan zhu , Tiwei Bie , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu Currently we have 2 types of vhost backends in QEMU: vhost kernel and vhost-user. The above patch provides a generic device for vDPA purpose, this vDPA device exposes to user space a non-vendor-specific configuration interface for setting up a vhost HW accelerator, this patch set introduces a third vhost backend called vhost-vdpa based on the vDPA interface. Vhost-vdpa usage: qemu-system-x86_64 -cpu host -enable-kvm \ ...... -netdev type=3Dvhost-vdpa,vhostdev=3D/dev/vhost-vdpa-id,id=3Dvhost-vdpa= 0 \ -device virtio-net-pci,netdev=3Dvhost-vdpa0,page-per-vq=3Don \ Signed-off-by: Lingshan zhu Signed-off-by: Tiwei Bie Signed-off-by: Cindy Lu Signed-off-by: Jason Wang Message-Id: <20200701145538.22333-14-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- configure | 21 ++ include/hw/virtio/vhost-backend.h | 4 +- include/hw/virtio/vhost-vdpa.h | 26 ++ include/hw/virtio/vhost.h | 7 + hw/net/vhost_net.c | 18 +- hw/net/virtio-net.c | 19 ++ hw/virtio/vhost-backend.c | 6 + hw/virtio/vhost-vdpa.c | 475 ++++++++++++++++++++++++++++++ docs/interop/index.rst | 1 + docs/interop/vhost-vdpa.rst | 17 ++ hw/virtio/Makefile.objs | 1 + qemu-options.hx | 12 + 12 files changed, 600 insertions(+), 7 deletions(-) create mode 100644 include/hw/virtio/vhost-vdpa.h create mode 100644 hw/virtio/vhost-vdpa.c create mode 100644 docs/interop/vhost-vdpa.rst diff --git a/configure b/configure index 4a22dcd563..3db7f20185 100755 --- a/configure +++ b/configure @@ -1575,6 +1575,10 @@ for opt do ;; --enable-vhost-user) vhost_user=3D"yes" ;; + --disable-vhost-vdpa) vhost_vdpa=3D"no" + ;; + --enable-vhost-vdpa) vhost_vdpa=3D"yes" + ;; --disable-vhost-kernel) vhost_kernel=3D"no" ;; --enable-vhost-kernel) vhost_kernel=3D"yes" @@ -1883,6 +1887,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vhost-crypto vhost-user-crypto backend support vhost-kernel vhost kernel backend support vhost-user vhost-user backend support + vhost-vdpa vhost-vdpa kernel backend support spice spice rbd rados block device (rbd) libiscsi iscsi support @@ -2394,6 +2399,10 @@ test "$vhost_user" =3D "" && vhost_user=3Dyes if test "$vhost_user" =3D "yes" && test "$mingw32" =3D "yes"; then error_exit "vhost-user isn't available on win32" fi +test "$vhost_vdpa" =3D "" && vhost_vdpa=3D$linux +if test "$vhost_vdpa" =3D "yes" && test "$linux" !=3D "yes"; then + error_exit "vhost-vdpa is only available on Linux" +fi test "$vhost_kernel" =3D "" && vhost_kernel=3D$linux if test "$vhost_kernel" =3D "yes" && test "$linux" !=3D "yes"; then error_exit "vhost-kernel is only available on Linux" @@ -2422,6 +2431,11 @@ test "$vhost_user_fs" =3D "" && vhost_user_fs=3D$vho= st_user if test "$vhost_user_fs" =3D "yes" && test "$vhost_user" =3D "no"; then error_exit "--enable-vhost-user-fs requires --enable-vhost-user" fi +#vhost-vdpa backends +test "$vhost_net_vdpa" =3D "" && vhost_net_vdpa=3D$vhost_vdpa +if test "$vhost_net_vdpa" =3D "yes" && test "$vhost_vdpa" =3D "no"; then + error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" +fi =20 # OR the vhost-kernel and vhost-user values for simplicity if test "$vhost_net" =3D ""; then @@ -6936,6 +6950,7 @@ echo "vhost-scsi support $vhost_scsi" echo "vhost-vsock support $vhost_vsock" echo "vhost-user support $vhost_user" echo "vhost-user-fs support $vhost_user_fs" +echo "vhost-vdpa support $vhost_vdpa" echo "Trace backends $trace_backends" if have_backend "simple"; then echo "Trace output file $trace_file-" @@ -7437,6 +7452,9 @@ fi if test "$vhost_net_user" =3D "yes" ; then echo "CONFIG_VHOST_NET_USER=3Dy" >> $config_host_mak fi +if test "$vhost_net_vdpa" =3D "yes" ; then + echo "CONFIG_VHOST_NET_VDPA=3Dy" >> $config_host_mak +fi if test "$vhost_crypto" =3D "yes" ; then echo "CONFIG_VHOST_CRYPTO=3Dy" >> $config_host_mak fi @@ -7452,6 +7470,9 @@ fi if test "$vhost_user" =3D "yes" ; then echo "CONFIG_VHOST_USER=3Dy" >> $config_host_mak fi +if test "$vhost_vdpa" =3D "yes" ; then + echo "CONFIG_VHOST_VDPA=3Dy" >> $config_host_mak +fi if test "$vhost_user_fs" =3D "yes" ; then echo "CONFIG_VHOST_USER_FS=3Dy" >> $config_host_mak fi diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index e7cb8d028c..8825bd278f 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -17,7 +17,8 @@ typedef enum VhostBackendType { VHOST_BACKEND_TYPE_NONE =3D 0, VHOST_BACKEND_TYPE_KERNEL =3D 1, VHOST_BACKEND_TYPE_USER =3D 2, - VHOST_BACKEND_TYPE_MAX =3D 3, + VHOST_BACKEND_TYPE_VDPA =3D 3, + VHOST_BACKEND_TYPE_MAX =3D 4, } VhostBackendType; =20 typedef enum VhostSetConfigType { @@ -170,6 +171,7 @@ typedef struct VhostOps { } VhostOps; =20 extern const VhostOps user_ops; +extern const VhostOps vdpa_ops; =20 int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type); diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h new file mode 100644 index 0000000000..6455663388 --- /dev/null +++ b/include/hw/virtio/vhost-vdpa.h @@ -0,0 +1,26 @@ +/* + * vhost-vdpa.h + * + * Copyright(c) 2017-2018 Intel Corporation. + * Copyright(c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef HW_VIRTIO_VHOST_VDPA_H +#define HW_VIRTIO_VHOST_VDPA_H + +#include "hw/virtio/virtio.h" + +typedef struct vhost_vdpa { + int device_fd; + uint32_t msg_type; + MemoryListener listener; +} VhostVDPA; + +extern AddressSpace address_space_memory; +extern int vhost_vdpa_get_device_id(struct vhost_dev *dev, + uint32_t *device_id); +#endif diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 085450c6f8..767a95ec0b 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -92,6 +92,13 @@ struct vhost_dev { const VhostDevConfigOps *config_ops; }; =20 +struct vhost_net { + struct vhost_dev dev; + struct vhost_virtqueue vqs[2]; + int backend; + NetClientState *nc; +}; + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeout); diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 4561665f6b..24d555e764 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -17,6 +17,7 @@ #include "net/net.h" #include "net/tap.h" #include "net/vhost-user.h" +#include "net/vhost-vdpa.h" =20 #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-net.h" @@ -33,12 +34,6 @@ #include "hw/virtio/vhost.h" #include "hw/virtio/virtio-bus.h" =20 -struct vhost_net { - struct vhost_dev dev; - struct vhost_virtqueue vqs[2]; - int backend; - NetClientState *nc; -}; =20 /* Features supported by host kernel. */ static const int kernel_feature_bits[] =3D { @@ -96,6 +91,11 @@ static const int *vhost_net_get_feature_bits(struct vhos= t_net *net) case NET_CLIENT_DRIVER_VHOST_USER: feature_bits =3D user_feature_bits; break; +#ifdef CONFIG_VHOST_NET_VDPA + case NET_CLIENT_DRIVER_VHOST_VDPA: + feature_bits =3D vdpa_feature_bits; + break; +#endif default: error_report("Feature bits not defined for this type: %d", net->nc->info->type); @@ -443,6 +443,12 @@ VHostNetState *get_vhost_net(NetClientState *nc) vhost_net =3D vhost_user_get_vhost_net(nc); assert(vhost_net); break; +#endif +#ifdef CONFIG_VHOST_NET_VDPA + case NET_CLIENT_DRIVER_VHOST_VDPA: + vhost_net =3D vhost_vdpa_get_vhost_net(nc); + assert(vhost_net); + break; #endif default: break; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index aff67a92df..0a54b1910a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -43,6 +43,7 @@ #include "monitor/qdev.h" #include "hw/pci/pci.h" #include "net_rx_pkt.h" +#include "hw/virtio/vhost.h" =20 #define VIRTIO_NET_VM_VERSION 11 =20 @@ -125,6 +126,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) VirtIONet *n =3D VIRTIO_NET(vdev); struct virtio_net_config netcfg; =20 + int ret =3D 0; + memset(&netcfg, 0 , sizeof(struct virtio_net_config)); virtio_stw_p(vdev, &netcfg.status, n->status); virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues); virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu); @@ -138,6 +141,15 @@ static void virtio_net_get_config(VirtIODevice *vdev, = uint8_t *config) virtio_stl_p(vdev, &netcfg.supported_hash_types, VIRTIO_NET_RSS_SUPPORTED_HASHES); memcpy(config, &netcfg, n->config_size); + + NetClientState *nc =3D qemu_get_queue(n->nic); + if (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA) { + ret =3D vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&= netcfg, + n->config_size); + if (ret !=3D -1) { + memcpy(config, &netcfg, n->config_size); + } + } } =20 static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *confi= g) @@ -153,6 +165,13 @@ static void virtio_net_set_config(VirtIODevice *vdev, = const uint8_t *config) memcpy(n->mac, netcfg.mac, ETH_ALEN); qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); } + + NetClientState *nc =3D qemu_get_queue(n->nic); + if (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA) { + vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, + 0, n->config_size, + VHOST_SET_CONFIG_TYPE_MASTER); + } } =20 static bool virtio_net_started(VirtIONet *n, uint8_t status) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 48905383f8..782b1d67d9 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -15,6 +15,7 @@ #include "qemu/main-loop.h" #include "standard-headers/linux/vhost_types.h" =20 +#include "hw/virtio/vhost-vdpa.h" #ifdef CONFIG_VHOST_KERNEL #include #include @@ -285,6 +286,11 @@ int vhost_set_backend_type(struct vhost_dev *dev, Vhos= tBackendType backend_type) case VHOST_BACKEND_TYPE_USER: dev->vhost_ops =3D &user_ops; break; +#endif +#ifdef CONFIG_VHOST_VDPA + case VHOST_BACKEND_TYPE_VDPA: + dev->vhost_ops =3D &vdpa_ops; + break; #endif default: error_report("Unknown vhost backend type"); diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c new file mode 100644 index 0000000000..6f2b01c25e --- /dev/null +++ b/hw/virtio/vhost-vdpa.c @@ -0,0 +1,475 @@ +/* + * vhost-vdpa + * + * Copyright(c) 2017-2018 Intel Corporation. + * Copyright(c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include +#include +#include +#include +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-backend.h" +#include "hw/virtio/virtio-net.h" +#include "hw/virtio/vhost-vdpa.h" +#include "qemu/main-loop.h" +#include +#include "sysemu/kvm.h" + +static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *secti= on) +{ + return (!memory_region_is_ram(section->mr) && + !memory_region_is_iommu(section->mr)) || + /* + * Sizing an enabled 64-bit BAR can cause spurious mappings to + * addresses in the upper part of the 64-bit address space. Th= ese + * are never accessed by the CPU and beyond the address width of + * some IOMMU hardware. TODO: VDPA should tell us the IOMMU wi= dth. + */ + section->offset_within_address_space & (1ULL << 63); +} + +static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr si= ze, + void *vaddr, bool readonly) +{ + struct vhost_msg_v2 msg; + int fd =3D v->device_fd; + int ret =3D 0; + + msg.type =3D v->msg_type; + msg.iotlb.iova =3D iova; + msg.iotlb.size =3D size; + msg.iotlb.uaddr =3D (uint64_t)vaddr; + msg.iotlb.perm =3D readonly ? VHOST_ACCESS_RO : VHOST_ACCESS_RW; + msg.iotlb.type =3D VHOST_IOTLB_UPDATE; + + if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { + error_report("failed to write, fd=3D%d, errno=3D%d (%s)", + fd, errno, strerror(errno)); + return -EIO ; + } + + return ret; +} + +static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, + hwaddr size) +{ + struct vhost_msg_v2 msg; + int fd =3D v->device_fd; + int ret =3D 0; + + msg.type =3D v->msg_type; + msg.iotlb.iova =3D iova; + msg.iotlb.size =3D size; + msg.iotlb.type =3D VHOST_IOTLB_INVALIDATE; + + if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { + error_report("failed to write, fd=3D%d, errno=3D%d (%s)", + fd, errno, strerror(errno)); + return -EIO ; + } + + return ret; +} + +static void vhost_vdpa_listener_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + struct vhost_vdpa *v =3D container_of(listener, struct vhost_vdpa, lis= tener); + hwaddr iova; + Int128 llend, llsize; + void *vaddr; + int ret; + + if (vhost_vdpa_listener_skipped_section(section)) { + return; + } + + if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK= ) !=3D + (section->offset_within_region & ~TARGET_PAGE_MASK))) { + error_report("%s received unaligned region", __func__); + return; + } + + iova =3D TARGET_PAGE_ALIGN(section->offset_within_address_space); + llend =3D int128_make64(section->offset_within_address_space); + llend =3D int128_add(llend, section->size); + llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + + if (int128_ge(int128_make64(iova), llend)) { + return; + } + + memory_region_ref(section->mr); + + /* Here we assume that memory_region_is_ram(section->mr)=3D=3Dtrue */ + + vaddr =3D memory_region_get_ram_ptr(section->mr) + + section->offset_within_region + + (iova - section->offset_within_address_space); + + llsize =3D int128_sub(llend, int128_make64(iova)); + + ret =3D vhost_vdpa_dma_map(v, iova, int128_get64(llsize), + vaddr, section->readonly); + if (ret) { + error_report("vhost vdpa map fail!"); + if (memory_region_is_ram_device(section->mr)) { + /* Allow unexpected mappings not to be fatal for RAM devices */ + error_report("map ram fail!"); + return ; + } + goto fail; + } + + return; + +fail: + if (memory_region_is_ram_device(section->mr)) { + error_report("failed to vdpa_dma_map. pci p2p may not work"); + return; + + } + /* + * On the initfn path, store the first error in the container so we + * can gracefully fail. Runtime, there's not much we can do other + * than throw a hardware error. + */ + error_report("vhost-vdpa: DMA mapping failed, unable to continue"); + return; + +} + +static void vhost_vdpa_listener_region_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + struct vhost_vdpa *v =3D container_of(listener, struct vhost_vdpa, lis= tener); + hwaddr iova; + Int128 llend, llsize; + int ret; + bool try_unmap =3D true; + + if (vhost_vdpa_listener_skipped_section(section)) { + return; + } + + if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK= ) !=3D + (section->offset_within_region & ~TARGET_PAGE_MASK))) { + error_report("%s received unaligned region", __func__); + return; + } + + iova =3D TARGET_PAGE_ALIGN(section->offset_within_address_space); + llend =3D int128_make64(section->offset_within_address_space); + llend =3D int128_add(llend, section->size); + llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + + if (int128_ge(int128_make64(iova), llend)) { + return; + } + + llsize =3D int128_sub(llend, int128_make64(iova)); + + if (try_unmap) { + ret =3D vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize)); + if (ret) { + error_report("vhost_vdpa dma unmap error!"); + } + } + + memory_region_unref(section->mr); +} +/* + * IOTLB API is used by vhost-vpda which requires incremental updating + * of the mapping. So we can not use generic vhost memory listener which + * depends on the addnop(). + */ +static const MemoryListener vhost_vdpa_memory_listener =3D { + .region_add =3D vhost_vdpa_listener_region_add, + .region_del =3D vhost_vdpa_listener_region_del, +}; + +static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int reques= t, + void *arg) +{ + struct vhost_vdpa *v =3D dev->opaque; + int fd =3D v->device_fd; + + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + + return ioctl(fd, request, arg); +} + +static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) +{ + uint8_t s; + + if (vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s)) { + return; + } + + s |=3D status; + + vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); +} + +static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque) +{ + struct vhost_vdpa *v; + uint64_t features; + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + + v =3D opaque; + dev->opaque =3D opaque ; + vhost_vdpa_call(dev, VHOST_GET_FEATURES, &features); + dev->backend_features =3D features; + v->listener =3D vhost_vdpa_memory_listener; + v->msg_type =3D VHOST_IOTLB_MSG_V2; + + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); + + return 0; +} + +static int vhost_vdpa_cleanup(struct vhost_dev *dev) +{ + struct vhost_vdpa *v; + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + v =3D dev->opaque; + memory_listener_unregister(&v->listener); + + dev->opaque =3D NULL; + return 0; +} + +static int vhost_vdpa_memslots_limit(struct vhost_dev *dev) +{ + return INT_MAX; +} + +static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, + struct vhost_memory *mem) +{ + + if (mem->padding) { + return -1; + } + + return 0; +} + +static int vhost_vdpa_set_features(struct vhost_dev *dev, + uint64_t features) +{ + int ret; + ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); + uint8_t status =3D 0; + if (ret) { + return ret; + } + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); + vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); + + return !(status & VIRTIO_CONFIG_S_FEATURES_OK); +} + +int vhost_vdpa_get_device_id(struct vhost_dev *dev, + uint32_t *device_id) +{ + return vhost_vdpa_call(dev, VHOST_VDPA_GET_DEVICE_ID, device_id); +} + +static int vhost_vdpa_reset_device(struct vhost_dev *dev) +{ + uint8_t status =3D 0; + + return vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); +} + +static int vhost_vdpa_get_vq_index(struct vhost_dev *dev, int idx) +{ + assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); + + return idx - dev->vq_index; +} + +static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev) +{ + int i; + for (i =3D 0; i < dev->nvqs; ++i) { + struct vhost_vring_state state =3D { + .index =3D dev->vq_index + i, + .num =3D 1, + }; + vhost_vdpa_call(dev, VHOST_VDPA_SET_VRING_ENABLE, &state); + } + return 0; +} + +static int vhost_vdpa_set_config(struct vhost_dev *dev, const uint8_t *dat= a, + uint32_t offset, uint32_t size, + uint32_t flags) +{ + struct vhost_vdpa_config *config; + int ret; + unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); + config =3D g_malloc(size + config_size); + if (config =3D=3D NULL) { + return -1; + } + config->off =3D offset; + config->len =3D size; + memcpy(config->buf, data, size); + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG, config); + g_free(config); + return ret; +} + +static int vhost_vdpa_get_config(struct vhost_dev *dev, uint8_t *config, + uint32_t config_len) +{ + struct vhost_vdpa_config *v_config; + unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); + int ret; + + v_config =3D g_malloc(config_len + config_size); + if (v_config =3D=3D NULL) { + return -1; + } + v_config->len =3D config_len; + v_config->off =3D 0; + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_CONFIG, v_config); + memcpy(config, v_config->buf, config_len); + g_free(v_config); + return ret; + } + +static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) +{ + struct vhost_vdpa *v =3D dev->opaque; + if (started) { + uint8_t status =3D 0; + memory_listener_register(&v->listener, &address_space_memory); + vhost_vdpa_set_vring_ready(dev); + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); + vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); + + return !(status & VIRTIO_CONFIG_S_DRIVER_OK); + } else { + vhost_vdpa_reset_device(dev); + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); + memory_listener_unregister(&v->listener); + + return 0; + } +} + +static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, + struct vhost_log *log) +{ + return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base); +} + +static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev, + struct vhost_vring_addr *addr) +{ + return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr); +} + +static int vhost_vdpa_set_vring_num(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return vhost_vdpa_call(dev, VHOST_SET_VRING_NUM, ring); +} + +static int vhost_vdpa_set_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring); +} + +static int vhost_vdpa_get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); +} + +static int vhost_vdpa_set_vring_kick(struct vhost_dev *dev, + struct vhost_vring_file *file) +{ + return vhost_vdpa_call(dev, VHOST_SET_VRING_KICK, file); +} + +static int vhost_vdpa_set_vring_call(struct vhost_dev *dev, + struct vhost_vring_file *file) +{ + return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file); +} + +static int vhost_vdpa_get_features(struct vhost_dev *dev, + uint64_t *features) +{ + return vhost_vdpa_call(dev, VHOST_GET_FEATURES, features); +} + +static int vhost_vdpa_set_owner(struct vhost_dev *dev) +{ + return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL); +} + +static int vhost_vdpa_vq_get_addr(struct vhost_dev *dev, + struct vhost_vring_addr *addr, struct vhost_virtqueue = *vq) +{ + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + addr->desc_user_addr =3D (uint64_t)(unsigned long)vq->desc_phys; + addr->avail_user_addr =3D (uint64_t)(unsigned long)vq->avail_phys; + addr->used_user_addr =3D (uint64_t)(unsigned long)vq->used_phys; + return 0; +} + +static bool vhost_vdpa_force_iommu(struct vhost_dev *dev) +{ + return true; +} + +const VhostOps vdpa_ops =3D { + .backend_type =3D VHOST_BACKEND_TYPE_VDPA, + .vhost_backend_init =3D vhost_vdpa_init, + .vhost_backend_cleanup =3D vhost_vdpa_cleanup, + .vhost_set_log_base =3D vhost_vdpa_set_log_base, + .vhost_set_vring_addr =3D vhost_vdpa_set_vring_addr, + .vhost_set_vring_num =3D vhost_vdpa_set_vring_num, + .vhost_set_vring_base =3D vhost_vdpa_set_vring_base, + .vhost_get_vring_base =3D vhost_vdpa_get_vring_base, + .vhost_set_vring_kick =3D vhost_vdpa_set_vring_kick, + .vhost_set_vring_call =3D vhost_vdpa_set_vring_call, + .vhost_get_features =3D vhost_vdpa_get_features, + .vhost_set_owner =3D vhost_vdpa_set_owner, + .vhost_set_vring_endian =3D NULL, + .vhost_backend_memslots_limit =3D vhost_vdpa_memslots_limit, + .vhost_set_mem_table =3D vhost_vdpa_set_mem_table, + .vhost_set_features =3D vhost_vdpa_set_features, + .vhost_reset_device =3D vhost_vdpa_reset_device, + .vhost_get_vq_index =3D vhost_vdpa_get_vq_index, + .vhost_get_config =3D vhost_vdpa_get_config, + .vhost_set_config =3D vhost_vdpa_set_config, + .vhost_requires_shm_log =3D NULL, + .vhost_migration_done =3D NULL, + .vhost_backend_can_merge =3D NULL, + .vhost_net_set_mtu =3D NULL, + .vhost_set_iotlb_callback =3D NULL, + .vhost_send_device_iotlb_msg =3D NULL, + .vhost_dev_start =3D vhost_vdpa_dev_start, + .vhost_get_device_id =3D vhost_vdpa_get_device_id, + .vhost_vq_get_addr =3D vhost_vdpa_vq_get_addr, + .vhost_force_iommu =3D vhost_vdpa_force_iommu, +}; diff --git a/docs/interop/index.rst b/docs/interop/index.rst index 049387ac6d..006f986420 100644 --- a/docs/interop/index.rst +++ b/docs/interop/index.rst @@ -20,3 +20,4 @@ Contents: qemu-ga vhost-user vhost-user-gpu + vhost-vdpa diff --git a/docs/interop/vhost-vdpa.rst b/docs/interop/vhost-vdpa.rst new file mode 100644 index 0000000000..0c70ba01bc --- /dev/null +++ b/docs/interop/vhost-vdpa.rst @@ -0,0 +1,17 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Vhost-vdpa Protocol +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +vDPA(Virtual data path acceleration) device is a device that uses +a datapath which complies with the virtio specifications with vendor +specific control path. vDPA devices can be both physically located on +the hardware or emulated by software. + +This document describes the vDPA support in qemu + +Here is the kernel commit here +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/= ?id=3D4c8cf31885f69e86be0b5b9e6677a26797365e1d + +TODO : More information will add later diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs index a986708186..fc91719b4a 100644 --- a/hw/virtio/Makefile.objs +++ b/hw/virtio/Makefile.objs @@ -5,6 +5,7 @@ obj-y +=3D virtio.o obj-$(CONFIG_VHOST) +=3D vhost.o vhost-backend.o common-obj-$(call lnot,$(CONFIG_VHOST)) +=3D vhost-stub.o obj-$(CONFIG_VHOST_USER) +=3D vhost-user.o +obj-$(CONFIG_VHOST_VDPA) +=3D vhost-vdpa.o =20 common-obj-$(CONFIG_VIRTIO_RNG) +=3D virtio-rng.o common-obj-$(CONFIG_VIRTIO_PCI) +=3D virtio-pci.o diff --git a/qemu-options.hx b/qemu-options.hx index 196f468786..fa1b19de4c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2418,6 +2418,10 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #ifdef CONFIG_POSIX "-netdev vhost-user,id=3Dstr,chardev=3Ddev[,vhostforce=3Don|off]\n" " configure a vhost-user network, backed by a chardev '= dev'\n" +#endif +#ifdef __linux__ + "-netdev vhost-vdpa,id=3Dstr,vhostdev=3D/path/to/dev\n" + " configure a vhost-vdpa network,Establish a vhost-vdpa= netdev\n" #endif "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on the hub with ID 'n'\n", QEMU_= ARCH_ALL) @@ -2897,6 +2901,14 @@ SRST -netdev type=3Dvhost-user,id=3Dnet0,chardev=3Dchr0 \ -device virtio-net-pci,netdev=3Dnet0 =20 +``-netdev vhost-vdpa,vhostdev=3D/path/to/dev`` + Establish a vhost-vdpa netdev. + + vDPA device is a device that uses a datapath which complies with + the virtio specifications with a vendor specific control path. + vDPA devices can be both physically located on the hardware or + emulated by software. + ``-netdev hubport,id=3Did,hubid=3Dhubid[,netdev=3Dnd]`` Create a hub port on the emulated hub with ID hubid. =20 --=20 MST From nobody Mon Apr 29 06:08:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593888797; cv=none; d=zohomail.com; s=zohoarc; b=lN/aWMBEFLIrl2kyhfaLcRe/+tw09lW+jz0QjhnRw0HBR1ouwAH58Om7j6QFti1LPyXHGx6Yu3qzfzEXq7HxD8PlK2XW6rdvFa8U4vS+oAnSB9DtbvWH8LWptIl3TrA3jcGZ9EgsqlRxdsBH2gLOKwXaZjyVHqAGGuAFD5h8luY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593888797; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4lWrpFH2CiygCO5uciNVA5FaqB2VaYbCK0AZiDA9UeM=; b=aeQVql2dmlUBHUU0awcO5580BhcW9MwZQ/+tp2YwFsGK/USwtbZ64gyJX84IN37qMjxO1VUYY/JJOI4AwUm6mIsO02lKEa3+mljeZZSJQF8ijjSFKtEE6arHY4n5vLI3f6h92AQTmFAuH9S7rrmZL2vkqxQU1osyQRUoKPX33rE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593888797270729.0151202125849; Sat, 4 Jul 2020 11:53:17 -0700 (PDT) Received: from localhost ([::1]:44754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnHn-0005U1-Ms for importer@patchew.org; Sat, 04 Jul 2020 14:53:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrmwZ-0005eh-UO for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23099 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrmwX-0001ip-DL for qemu-devel@nongnu.org; Sat, 04 Jul 2020 14:31:19 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-dNp_sj52PNGqdCQ3br8Dxg-1; Sat, 04 Jul 2020 14:31:13 -0400 Received: by mail-wm1-f70.google.com with SMTP id g6so34363095wmk.4 for ; Sat, 04 Jul 2020 11:31:12 -0700 (PDT) Received: from redhat.com (bzq-79-182-31-92.red.bezeqint.net. [79.182.31.92]) by smtp.gmail.com with ESMTPSA id n125sm18032509wme.30.2020.07.04.11.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 11:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593887476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4lWrpFH2CiygCO5uciNVA5FaqB2VaYbCK0AZiDA9UeM=; b=fjHLCf6GowtCyhkReK4Zq1zDtHCWQOeIH6mq5fUNujYI31uCw0fAZhU1reu7H7E9PUWitm 0sDVr8WVPuMPE51ZvkfHQqVc8kEDCBdSc1hDkrpWNmJMZBvffoUmK7Tw6tQv2pHQE0aU7m GMFpBJJIswsI+DH2G6/2AXqBZl9xDgU= X-MC-Unique: dNp_sj52PNGqdCQ3br8Dxg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4lWrpFH2CiygCO5uciNVA5FaqB2VaYbCK0AZiDA9UeM=; b=SlyCi58FEJlsa35jIR/hT9frmSTaz3eAy0JvZowKav/7H/uCOQNRfNxUfSQEt1MW9I BrOxwp2lkMfABuqmdHafhE432781OViVdRwPBx9cndzIEP6MaiGVrAWlZ+tEx9B50/2m iI51nBTxtGCuldYgu7t1L8S55WMpqRyv2PSwNvdfJLkzS1t7jonlls47FtESrmrSOP44 lS2AQdapFlzWkp/Ys/vXNNdYroWAF5qEnLf7nggo07izVwLN+jrtMsurGZOShsC9gtlV /ZJzg+YtyufxFwXNhVrch1t8Pl2oaHc14tAfM5AJlOkTDej4V/iyvu/dmuWE4jnoJIfj F8TA== X-Gm-Message-State: AOAM5322pZ/IjoDycWzZA/KSiBeVOLRIxM3I0tAYInoWKvIkdjM5bnaE BZ4CcvfYbkrTliEsa0dBLYU7iui4jfW8krN6r1ZsmUrpgKom9ND3VTV6AoFjNK6NjN4I9L22mA4 LAA9bTnjjSPnjj2Y= X-Received: by 2002:adf:9c8c:: with SMTP id d12mr40909300wre.369.1593887471377; Sat, 04 Jul 2020 11:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMvJk8BJXRgLhMO9P/k6ZtefYVHAqTbh9hbFSDwPhFpsWNYj6RLANadDBTTHltxG/et/VKOQ== X-Received: by 2002:adf:9c8c:: with SMTP id d12mr40909282wre.369.1593887471039; Sat, 04 Jul 2020 11:31:11 -0700 (PDT) Date: Sat, 4 Jul 2020 14:31:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 41/41] vhost-vdpa: introduce vhost-vdpa net client Message-ID: <20200704182750.1088103-42-mst@redhat.com> References: <20200704182750.1088103-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200704182750.1088103-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 11:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu , Tiwei Bie , Jason Wang , Markus Armbruster , Lingshan Zhu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch set introduces a new net client type: vhost-vdpa. vhost-vdpa net client will set up a vDPA device which is specified by a "vhostdev" parameter. Signed-off-by: Lingshan Zhu Signed-off-by: Tiwei Bie Signed-off-by: Cindy Lu Signed-off-by: Jason Wang Message-Id: <20200701145538.22333-15-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- qapi/net.json | 28 ++++- include/net/vhost-vdpa.h | 22 ++++ net/clients.h | 2 + net/net.c | 3 + net/vhost-vdpa.c | 228 +++++++++++++++++++++++++++++++++++++++ net/Makefile.objs | 2 +- 6 files changed, 282 insertions(+), 3 deletions(-) create mode 100644 include/net/vhost-vdpa.h create mode 100644 net/vhost-vdpa.c diff --git a/qapi/net.json b/qapi/net.json index 9244c9af56..558d520a2f 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -428,16 +428,39 @@ '*vhostforce': 'bool', '*queues': 'int' } } =20 +## +# @NetdevVhostVDPAOptions: +# +# Vhost-vdpa network backend +# +# vDPA device is a device that uses a datapath which complies with the vir= tio +# specifications with a vendor specific control path. +# +# @vhostdev: path of vhost-vdpa device +# (default:'/dev/vhost-vdpa-0') +# +# @queues: number of queues to be created for multiqueue vhost-vdpa +# (default: 1) +# +# Since: 5.1 +## +{ 'struct': 'NetdevVhostVDPAOptions', + 'data': { + '*vhostdev': 'str', + '*queues': 'int' } } + ## # @NetClientDriver: # # Available netdev drivers. # # Since: 2.7 +# +# @vhost-vdpa since 5.1 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user' ] } + 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] } =20 ## # @Netdev: @@ -465,7 +488,8 @@ 'bridge': 'NetdevBridgeOptions', 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', - 'vhost-user': 'NetdevVhostUserOptions' } } + 'vhost-user': 'NetdevVhostUserOptions', + 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } =20 ## # @NetFilterDirection: diff --git a/include/net/vhost-vdpa.h b/include/net/vhost-vdpa.h new file mode 100644 index 0000000000..45e34b7cfc --- /dev/null +++ b/include/net/vhost-vdpa.h @@ -0,0 +1,22 @@ +/* + * vhost-vdpa.h + * + * Copyright(c) 2017-2018 Intel Corporation. + * Copyright(c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef VHOST_VDPA_H +#define VHOST_VDPA_H + +#define TYPE_VHOST_VDPA "vhost-vdpa" + +struct vhost_net *vhost_vdpa_get_vhost_net(NetClientState *nc); +uint64_t vhost_vdpa_get_acked_features(NetClientState *nc); + +extern const int vdpa_feature_bits[]; + +#endif /* VHOST_VDPA_H */ diff --git a/net/clients.h b/net/clients.h index a6ef267e19..92f9b59aed 100644 --- a/net/clients.h +++ b/net/clients.h @@ -61,4 +61,6 @@ int net_init_netmap(const Netdev *netdev, const char *nam= e, int net_init_vhost_user(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); =20 +int net_init_vhost_vdpa(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp); #endif /* QEMU_NET_CLIENTS_H */ diff --git a/net/net.c b/net/net.c index 9099a327dd..94dc546fb2 100644 --- a/net/net.c +++ b/net/net.c @@ -966,6 +966,9 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIV= ER__MAX])( #ifdef CONFIG_VHOST_NET_USER [NET_CLIENT_DRIVER_VHOST_USER] =3D net_init_vhost_user, #endif +#ifdef CONFIG_VHOST_NET_VDPA + [NET_CLIENT_DRIVER_VHOST_VDPA] =3D net_init_vhost_vdpa, +#endif #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3] =3D net_init_l2tpv3, #endif diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c new file mode 100644 index 0000000000..bc0e0d2d35 --- /dev/null +++ b/net/vhost-vdpa.c @@ -0,0 +1,228 @@ +/* + * vhost-vdpa.c + * + * Copyright(c) 2017-2018 Intel Corporation. + * Copyright(c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "clients.h" +#include "net/vhost_net.h" +#include "net/vhost-vdpa.h" +#include "hw/virtio/vhost-vdpa.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qapi/error.h" +#include +#include +#include "standard-headers/linux/virtio_net.h" +#include "monitor/monitor.h" +#include "hw/virtio/vhost.h" + +/* Todo:need to add the multiqueue support here */ +typedef struct VhostVDPAState { + NetClientState nc; + struct vhost_vdpa vhost_vdpa; + VHostNetState *vhost_net; + uint64_t acked_features; + bool started; +} VhostVDPAState; + +const int vdpa_feature_bits[] =3D { + VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_RING_F_INDIRECT_DESC, + VIRTIO_RING_F_EVENT_IDX, + VIRTIO_F_ANY_LAYOUT, + VIRTIO_F_VERSION_1, + VIRTIO_NET_F_CSUM, + VIRTIO_NET_F_GUEST_CSUM, + VIRTIO_NET_F_GSO, + VIRTIO_NET_F_GUEST_TSO4, + VIRTIO_NET_F_GUEST_TSO6, + VIRTIO_NET_F_GUEST_ECN, + VIRTIO_NET_F_GUEST_UFO, + VIRTIO_NET_F_HOST_TSO4, + VIRTIO_NET_F_HOST_TSO6, + VIRTIO_NET_F_HOST_ECN, + VIRTIO_NET_F_HOST_UFO, + VIRTIO_NET_F_MRG_RXBUF, + VIRTIO_NET_F_MTU, + VIRTIO_F_IOMMU_PLATFORM, + VIRTIO_F_RING_PACKED, + VIRTIO_NET_F_GUEST_ANNOUNCE, + VHOST_INVALID_FEATURE_BIT +}; + +VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + return s->vhost_net; +} + +uint64_t vhost_vdpa_get_acked_features(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + s->acked_features =3D vhost_net_get_acked_features(s->vhost_net); + + return s->acked_features; +} + +static int vhost_vdpa_net_check_device_id(struct vhost_net *net) +{ + uint32_t device_id; + int ret; + struct vhost_dev *hdev; + + hdev =3D (struct vhost_dev *)&net->dev; + ret =3D hdev->vhost_ops->vhost_get_device_id(hdev, &device_id); + if (device_id !=3D VIRTIO_ID_NET) { + return -ENOTSUP; + } + return ret; +} + +static void vhost_vdpa_del(NetClientState *ncs) +{ + VhostVDPAState *s; + assert(ncs->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + s =3D DO_UPCAST(VhostVDPAState, nc, ncs); + if (s->vhost_net) { + vhost_net_cleanup(s->vhost_net); + } +} + +static int vhost_vdpa_add(NetClientState *ncs, void *be) +{ + VhostNetOptions options; + struct vhost_net *net =3D NULL; + VhostVDPAState *s; + int ret; + + options.backend_type =3D VHOST_BACKEND_TYPE_VDPA; + assert(ncs->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + s =3D DO_UPCAST(VhostVDPAState, nc, ncs); + options.net_backend =3D ncs; + options.opaque =3D be; + options.busyloop_timeout =3D 0; + + net =3D vhost_net_init(&options); + if (!net) { + error_report("failed to init vhost_net for queue"); + goto err; + } + if (s->vhost_net) { + vhost_net_cleanup(s->vhost_net); + g_free(s->vhost_net); + } + s->vhost_net =3D net; + ret =3D vhost_vdpa_net_check_device_id(net); + if (ret) { + goto err; + } + return 0; +err: + if (net) { + vhost_net_cleanup(net); + } + vhost_vdpa_del(ncs); + return -1; +} + +static void vhost_vdpa_cleanup(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + + if (s->vhost_net) { + vhost_net_cleanup(s->vhost_net); + g_free(s->vhost_net); + s->vhost_net =3D NULL; + } +} + +static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc) +{ + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + return true; +} + +static bool vhost_vdpa_has_ufo(NetClientState *nc) +{ + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + uint64_t features =3D 0; + features |=3D (1ULL << VIRTIO_NET_F_HOST_UFO); + features =3D vhost_net_get_features(s->vhost_net, features); + return !!(features & (1ULL << VIRTIO_NET_F_HOST_UFO)); + +} + +static NetClientInfo net_vhost_vdpa_info =3D { + .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, + .size =3D sizeof(VhostVDPAState), + .cleanup =3D vhost_vdpa_cleanup, + .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, + .has_ufo =3D vhost_vdpa_has_ufo, +}; + +static int net_vhost_vdpa_init(NetClientState *peer, const char *device, + const char *name, const char *vhostdev) +{ + NetClientState *nc =3D NULL; + VhostVDPAState *s; + int vdpa_device_fd =3D -1; + int ret =3D 0; + assert(name); + nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); + snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); + nc->queue_index =3D 0; + s =3D DO_UPCAST(VhostVDPAState, nc, nc); + vdpa_device_fd =3D qemu_open(vhostdev, O_RDWR); + if (vdpa_device_fd =3D=3D -1) { + return -errno; + } + s->vhost_vdpa.device_fd =3D vdpa_device_fd; + ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); + assert(s->vhost_net); + return ret; +} + +static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp) +{ + const char *name =3D opaque; + const char *driver, *netdev; + + driver =3D qemu_opt_get(opts, "driver"); + netdev =3D qemu_opt_get(opts, "netdev"); + if (!driver || !netdev) { + return 0; + } + if (strcmp(netdev, name) =3D=3D 0 && + !g_str_has_prefix(driver, "virtio-net-")) { + error_setg(errp, "vhost-vdpa requires frontend driver virtio-net-*= "); + return -1; + } + return 0; +} + +int net_init_vhost_vdpa(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) +{ + const NetdevVhostVDPAOptions *opts; + + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + opts =3D &netdev->u.vhost_vdpa; + /* verify net frontend */ + if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net, + (char *)name, errp)) { + return -1; + } + return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev= ); +} diff --git a/net/Makefile.objs b/net/Makefile.objs index c5d076d19c..5ab45545db 100644 --- a/net/Makefile.objs +++ b/net/Makefile.objs @@ -26,7 +26,7 @@ tap-obj-$(CONFIG_SOLARIS) =3D tap-solaris.o tap-obj-y ?=3D tap-stub.o common-obj-$(CONFIG_POSIX) +=3D tap.o $(tap-obj-y) common-obj-$(CONFIG_WIN32) +=3D tap-win32.o - +common-obj-$(CONFIG_VHOST_NET_VDPA) +=3D vhost-vdpa.o vde.o-libs =3D $(VDE_LIBS) =20 common-obj-$(CONFIG_CAN_BUS) +=3D can/ --=20 MST