From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569409775; cv=none; d=zoho.com; s=zohoarc; b=CxQiPeelTw5TrbYLfvxGNY2FHb0uYdDfmhqRjMahwisBFKyJXLaFR7EdUEOuue0x28xHbWw2/JlhccIMJqppxgo4iyjwI8yZwecltTzeQV7d88nSAu40ukuDTHr4fP1j11ie7msw7s40bBF4X9YENMN3VS4S/Bh8KZgi/xzDt54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569409775; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=GKWNqiYwVrsn0putnRnrghN5ULrhO4lIMes6GImbrWQ=; b=e/BkAfB76Hyr5BllYqMvCEXwAUENwnFSidBjcYkAk8nidsSus+3UorlBIM80o6i4B5C/sO6lk8rAspPM7pNguC7+1y/uHhhqAyIsKolj1fiLik5+LK1i8gGtL2Tr6Y2z8UPhpONEuGAWJmJLiryDAjh978V83I3txDvP4wC6gio= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569409775158597.8061650852603; Wed, 25 Sep 2019 04:09:35 -0700 (PDT) Received: from localhost ([::1]:48190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5Ar-0001bJ-E7 for importer@patchew.org; Wed, 25 Sep 2019 07:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44769) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3R0qLXQYKCvoucogkfiqqing.eqosgow-fgxgnpqpipw.qti@flex--sameid.bounces.google.com>) id 1iD58F-0007kI-SS for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3R0qLXQYKCvoucogkfiqqing.eqosgow-fgxgnpqpipw.qti@flex--sameid.bounces.google.com>) id 1iD58E-0004Kh-OT for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:51 -0400 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]:36272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3R0qLXQYKCvoucogkfiqqing.eqosgow-fgxgnpqpipw.qti@flex--sameid.bounces.google.com>) id 1iD58E-0004Ic-IF for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:50 -0400 Received: by mail-wm1-x34a.google.com with SMTP id k184so1941700wmk.1 for ; Wed, 25 Sep 2019 04:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=GKWNqiYwVrsn0putnRnrghN5ULrhO4lIMes6GImbrWQ=; b=qv8uaaQ2HAdNlrWSNmuGHrSyNvLRnBKqOU4VlQDxSQtILzBVYxEA+HVjLYXhGLWLQF DzblVQXyj1jsEa5mj+ZSU4HWVyqZNtBuSq1tZrRTf2tkMuXDxQpBkA6jUMefOF1h6Ptq JWzQ3qk/C3U0iSqtB/i9n1fpcbbaA9j9hoo1ARnRud2SdW7KJr6o89F0FmCaI+r7MeP4 UXtqx/hOcvdJdJhLOcAEP8Ge0kWdYVR22G2bew3kuFOfT4wcl+YoUw1SsaBvxPzKCw2J xILthFEQJMDqwVfeHAxLz447h2z9KHprcOpgvr4koqGljor19ptyC/8owthY08JUTI9r aKRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GKWNqiYwVrsn0putnRnrghN5ULrhO4lIMes6GImbrWQ=; b=WQ3l2vYtO9HfK0uA4eO4eEnJs/KuAwo1Aak88Ew3OQ7qQExkkNz8/ddawIhiHcY5Ls s4C7N0f1iy597LnfSEKAJkbiiVwwugr3Ve4IkU3t0np4KxUYIJw6IidurK5PW8b0qb1d cvp9yf2awynWh2/mTSFVUX5ATgjVUfgnlE1OVMZDJBWSp2SP/sHHqWkGgpZrPxlQrV1/ Bbg02VT+Cb32oONvDK5OdaY8P2MdCWJabiX0s0Q2KnAHV8vaY845IMyebCaXrIaeV1qH ajfheU6EW7mTX29B2GO3zxqfCjEjmc0uZq2vc+a4Y5GFNNeipwyotJ1w8hMF6GGGk3pL NgKQ== X-Gm-Message-State: APjAAAW4IpB6F35xQE5X2BaOiUU39vm58grkAYb6eGobWtm2QO2kQg6G fX0pQ7zH5TOSnMw18tFx2NWWP7LVNas5jBXtd/4ewzEUrjWYxhlMBiftbX56SAkOyXqvH7HsmBr sh3MFiwJjWSbL3mNYyM8a40UCWcBRUKiZhm6SVJviuOURpQLXO+qAh3cj2EqY X-Google-Smtp-Source: APXvYqzFtaLuUeiiTrWsNy1fSb8dotL3CjrEb7LFgBfYrQaoJuzmCVsDNs+5hXOSvYxm8rBzntACvWaqrgE= X-Received: by 2002:adf:eb42:: with SMTP id u2mr8730661wrn.307.1569409607592; Wed, 25 Sep 2019 04:06:47 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:32 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-2-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 1/8] block: Refactor macros - fix tabbing To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::34a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Fixing tabbing in block related macros. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ide/qdev.c | 2 +- include/hw/block/block.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6fba6b62b8..6dd219944f 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -290,7 +290,7 @@ static void ide_drive_realize(IDEDevice *dev, Error **e= rrp) DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf), \ DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf), \ DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ - DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ + DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),\ DEFINE_PROP_STRING("model", IDEDrive, dev.model) =20 diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 607539057a..fd55a30bca 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -50,21 +50,21 @@ static inline unsigned int get_physical_block_exp(Block= Conf *conf) _conf.logical_block_size), \ DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ _conf.physical_block_size), \ - DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ + DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \ - DEFINE_PROP_UINT32("discard_granularity", _state, \ - _conf.discard_granularity, -1), \ - DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ - ON_OFF_AUTO_AUTO), \ + DEFINE_PROP_UINT32("discard_granularity", _state, \ + _conf.discard_granularity, -1), \ + DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ + ON_OFF_AUTO_AUTO), \ DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) =20 #define DEFINE_BLOCK_PROPERTIES(_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.blk), \ DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) =20 -#define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ - DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ - DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ +#define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ + DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ + DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0) =20 #define DEFINE_BLOCK_ERROR_PROPERTIES(_state, _conf) \ --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569410080; cv=none; d=zoho.com; s=zohoarc; b=ZEMp3BSigK0tC0yPCCeimpyTy33Qs44NSP+HlaWs/YDIYdhMpwHwlS8PTYDUcofLqfs31Rbuzzpo4LudUOPdC9w6o9MyyIDMJkfJkPhSb4/4xVOTaUWP9SM5Xkasz/paYSmVM2c/y3o014E13zw9FSP5LxUSlVHAgrFw0IPXnPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569410080; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=wQfLQEhmK8gGTLXrGitPL7fj5j2zg1DshrzOt/Wj1N8=; b=Dz2EC39bqzcH7K0OiuVi3EGc1m6cjF8PuCeRi043oNrcaG+a7TIxoGeOFxkBVE7PorgqTGYH1xIxgJx1g0iB4TNGPLf9KYL/p0wcNxNVqLBNULITSlTY1S+IPPSw5BjQOhL2vQckHkx6UwCHpnnSt3xtkVTXlDfmJDO6QoUuiD4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569410080556602.6552222885277; Wed, 25 Sep 2019 04:14:40 -0700 (PDT) Received: from localhost ([::1]:48230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5Fm-00074N-GE for importer@patchew.org; Wed, 25 Sep 2019 07:14:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44795) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3S0qLXQYKCv4ygskojmuumrk.iuswks0-jk1krtutmt0.uxm@flex--sameid.bounces.google.com>) id 1iD58I-0007ou-5H for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3S0qLXQYKCv4ygskojmuumrk.iuswks0-jk1krtutmt0.uxm@flex--sameid.bounces.google.com>) id 1iD58H-0004NG-5l for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:54 -0400 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]:34750) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3S0qLXQYKCv4ygskojmuumrk.iuswks0-jk1krtutmt0.uxm@flex--sameid.bounces.google.com>) id 1iD58H-0004Ma-0d for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:53 -0400 Received: by mail-wr1-x449.google.com with SMTP id j2so2187942wre.1 for ; Wed, 25 Sep 2019 04:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wQfLQEhmK8gGTLXrGitPL7fj5j2zg1DshrzOt/Wj1N8=; b=YFyIaGWXPT8GzhIgXk+7H8kjpGkg6WzlWq0c6P359HSXyTuZbcRYM2QRT79snxqqST BIhwrE+QoZR6xpFcc19J9ry2QrIqmBGq/8X/G2fR2KGsUSJY6Ezh+41fLm0N2P4870lr 65UqFC0cZ70dvEGlg2CfQJDzxsng/NweY4hAkkJJXkb2SZbQJQbSdfOFvfsu07jvb8G1 KWbPmbN25Uzh5bl0TPZ5fcmXprMU6eIZpn/dOJH59J0zDbcqytE+dY3TOTC3Mda7+ife jxWWkREdYctczyl4GtvlvmagCqhP5TlnewB1JPY5cdLmF9qk1dKD0dVbf16jt4dQOtAp ZayA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wQfLQEhmK8gGTLXrGitPL7fj5j2zg1DshrzOt/Wj1N8=; b=c9akByEI6nVE2XlMhwBYMX972HtY3wuVQnRS6V1XoEgzIzxyMrA3SM924o47Vs2SYF TDzmxk6KfrLsdWHQ12FvJbINUCH70ZgqigodQNk1rt8+/iPV7AmLNZZnLMmB3qMX2JAL EFgY9/YabGuyMx6rY9Na/u27z5sreitBRnNNtwhPjYx424iNhMXDKfBxNrxDePLvnU4d RSzzg4PeRvx4p6rYzxUhcreG6jYsEtdmb4+jqXuc3DtZUvQLivIpLaLyA5mPQM5zYebE zJe/KKQVo24oNIwI0nZU2LpEGJGI6t7GXQSuXo26MvRzPNNUz1A1ndJ/vLgLQJqla0Rl 0RyA== X-Gm-Message-State: APjAAAXX1HATLDka/4U0Uq/iMpnHx6x/1kK54q1maIHfxpKX1Z/9r3p9 vqIjhUdO9+3v6e1mk7iK1svLjeg7mIBpEc1vcoqT7kR9hsGogIzdM+l5bKTZBGaZ1aqzPcWiaHF hzMSTzpEQnc570M4jkIqWgbVumD6rwV6p2JGGdzjMAbU5h5Iiimv3tuWf+Dpa X-Google-Smtp-Source: APXvYqwbiy5AcLGpgpOvEX+dSWV45Mq2I7MVpTEbdcZtR6LvUmPTYcrxWYConl0V1VXmAAR5EJ1SPBuLODU= X-Received: by 2002:a5d:4742:: with SMTP id o2mr8365092wrs.253.1569409611655; Wed, 25 Sep 2019 04:06:51 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:33 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-3-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 2/8] block: Support providing LCHS from user To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::449 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add logical geometry variables to BlockConf. A user can now supply "lcyls", "lheads" & "lsecs" for any HD device that supports CHS ("cyls", "heads", "secs"). These devices include: * ide-hd * scsi-hd * virtio-blk-pci In future commits we will use the provided LCHS and pass it to the BIOS through fw_cfg to be supplied using INT13 routines. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- include/hw/block/block.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index fd55a30bca..d7246f3862 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -26,6 +26,7 @@ typedef struct BlockConf { uint32_t discard_granularity; /* geometry, not all devices use this */ uint32_t cyls, heads, secs; + uint32_t lcyls, lheads, lsecs; OnOffAuto wce; bool share_rw; BlockdevOnError rerror; @@ -65,7 +66,10 @@ static inline unsigned int get_physical_block_exp(BlockC= onf *conf) #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ - DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0) + DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0), \ + DEFINE_PROP_UINT32("lcyls", _state, _conf.lcyls, 0), \ + DEFINE_PROP_UINT32("lheads", _state, _conf.lheads, 0), \ + DEFINE_PROP_UINT32("lsecs", _state, _conf.lsecs, 0) =20 #define DEFINE_BLOCK_ERROR_PROPERTIES(_state, _conf) \ DEFINE_PROP_BLOCKDEV_ON_ERROR("rerror", _state, _conf.rerror, \ --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569409789; cv=none; d=zoho.com; s=zohoarc; b=N8bzFPirCV5GzTGWuP2nOglGwqd3sCr5McUAYNHyWT/J6fdsAlXsVXhPgRgcZGb3K8rPfQlqoG05PCCxHpH2omXAzlki0I7hKzPkTcRCG9H0+Epx8fBSBtpjV25CbigRzKzks6zDCtj35woJSEH9CKOrY0J9JuGD+Jwbxa8G49I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569409789; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=D4/WwEuQfb0OwGTdHL/wsfMkxNs9t/uthskzigDltsc=; b=Ak7cEexlKSgGiniRO/lu+WUElkHn1aNYioy8oRZKH15m4z579PVaNFmbLpKxDusCrDRnIQTcELUr2Ly+3ScW6lzZ2UddEwQkIRo46bBHFRAg+/UDKOyAEfpwpMIRn8/yIWan5yZXtF2N6pMXDm5sjkoBiLhrNexF4hWTPjr8uow= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156940978963834.19650532208891; Wed, 25 Sep 2019 04:09:49 -0700 (PDT) Received: from localhost ([::1]:48192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5B4-0001nu-Hy for importer@patchew.org; Wed, 25 Sep 2019 07:09:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44829) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3T0qLXQYKCgQweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1iD58M-0007ws-Hp for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3T0qLXQYKCgQweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1iD58L-0004Q9-EP for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:58 -0400 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]:35487) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3T0qLXQYKCgQweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1iD58L-0004PJ-9D for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:06:57 -0400 Received: by mail-wm1-x34a.google.com with SMTP id k9so1944986wmb.0 for ; Wed, 25 Sep 2019 04:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=D4/WwEuQfb0OwGTdHL/wsfMkxNs9t/uthskzigDltsc=; b=CKP+xxBXKbd6sJ6s1kT6DlCCCqq4Hv0YuAOPqLXuI100erdqtHh2+pr+qXBQOPx+bP T+5MjmV7+Dt1qKBWWBjmKZGQ1yIOeC+NmGKG0MH6gxO38rlDJjlLcN8eVoeP9NbXtBfe BWNlQrpCxzIGfayhIwzEQbbB2U9Zanf/N0bB6LOMfA3MKdsZwtY7PrMb5Mi/q2p5eWi4 10h3fWESQ7BIn4KSh6MdZq7Ggxn3k6G0RAkf000HZdlIKoJqTZICbna8HQO5wHCYtiUK swtIpYOw+I9J3sDdG6MZxa3OrCYsv4xNZyx/RQEvcgb6hpIV5OXEuAZ3FAtI+cNlpI8u mUIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=D4/WwEuQfb0OwGTdHL/wsfMkxNs9t/uthskzigDltsc=; b=TOqajF5hC4mXWRj3uONPwFe8r6zKUMYCefkvwtYyTg1tpL53/G4uIe0CuG1SUM+dzu 6AR5/pL11nhxy+BDOToZ3iOMz4qg+3CuEhGjeEhFMVv84gAh66muAJW/0ZiyLB/JaD+P ydtetAUtAx6fKx7ge8qpqvApFfPgCOrwGkhtVLQEtVLM5hqkzRgx/ltXve5lpwNF1QIm PaApAdOdsPrdrT5lQoHq/KW1ijgVptCCA7RVTc4FK+ah2NoePVSiCeTfxejmpeADj6zK 47SRyoIO3BQS5bJmLFeVnV4J6su/qY9x/6R9PwYXzun+PTE1xmyMjT3JO4vnTueokeF4 edPg== X-Gm-Message-State: APjAAAX7sLER9tuXg1z4WqakjuuP/moBXM0MEIOhrcSA4sXgmBNJ99Sq gSEzo40zJTw2o7UXOTcu7GwBSy4V68fI3ZrSLPVXIPYSeIIOhzQ5TdY9CdnxT6+oGKblg79eC8E BSY5UQATAaBTrONssSKNxBBoDCcgJ+bNnZM5YAOBLKkK1EQ5noQ77Xq+4aGW2 X-Google-Smtp-Source: APXvYqwP3pUkQht+a8Vbqi9tV8ffJFe2CuKJBedfO3HE6n1nzU5HMGwOD0Id1LbAvmqQg5Jg+utKsXsPrNA= X-Received: by 2002:a5d:5229:: with SMTP id i9mr8756866wra.76.1569409615715; Wed, 25 Sep 2019 04:06:55 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:34 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-4-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 3/8] bootdevice: Add interface to gather LCHS To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::34a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add an interface to provide direct logical CHS values for boot devices. We will use this interface in the next commits. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- bootdevice.c | 55 +++++++++++++++++++++++++++++++++++++++++ include/sysemu/sysemu.h | 3 +++ 2 files changed, 58 insertions(+) diff --git a/bootdevice.c b/bootdevice.c index 1d225202f9..bc5e1c2de4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -343,3 +343,58 @@ void device_add_bootindex_property(Object *obj, int32_= t *bootindex, /* initialize devices' bootindex property to -1 */ object_property_set_int(obj, -1, name, NULL); } + +typedef struct FWLCHSEntry FWLCHSEntry; + +struct FWLCHSEntry { + QTAILQ_ENTRY(FWLCHSEntry) link; + DeviceState *dev; + char *suffix; + uint32_t lcyls; + uint32_t lheads; + uint32_t lsecs; +}; + +static QTAILQ_HEAD(, FWLCHSEntry) fw_lchs =3D + QTAILQ_HEAD_INITIALIZER(fw_lchs); + +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs) +{ + FWLCHSEntry *node; + + if (!lcyls && !lheads && !lsecs) { + return; + } + + assert(dev !=3D NULL || suffix !=3D NULL); + + node =3D g_malloc0(sizeof(FWLCHSEntry)); + node->suffix =3D g_strdup(suffix); + node->dev =3D dev; + node->lcyls =3D lcyls; + node->lheads =3D lheads; + node->lsecs =3D lsecs; + + QTAILQ_INSERT_TAIL(&fw_lchs, node, link); +} + +void del_boot_device_lchs(DeviceState *dev, const char *suffix) +{ + FWLCHSEntry *i; + + if (dev =3D=3D NULL) { + return; + } + + QTAILQ_FOREACH(i, &fw_lchs, link) { + if ((!suffix || !g_strcmp0(i->suffix, suffix)) && + i->dev =3D=3D dev) { + QTAILQ_REMOVE(&fw_lchs, i, link); + g_free(i->suffix); + g_free(i); + + break; + } + } +} diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 44f18eb739..5bc5c79cbc 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -103,6 +103,9 @@ void device_add_bootindex_property(Object *obj, int32_t= *bootindex, DeviceState *dev, Error **errp); void restore_boot_order(void *opaque); void validate_bootdevices(const char *devices, Error **errp); +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs); +void del_boot_device_lchs(DeviceState *dev, const char *suffix); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569410282; cv=none; d=zoho.com; s=zohoarc; b=fZ4Nk8GRv4okRL6EYOD3gWvVwUf9ZzCTOoDgHYmGhTvNATyqlDc33QjNgFmnqVG4QGne28ahSx3C0dIGTe78Rn+vY6cZ0sofsHJH6Jd/eBdsyXjnpPa2OovQ4AzYLaF7s2mXrsXEtiLvXzj0jQbR8uvHNjDNn1I2ZB/gFXBmsl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569410282; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=7sLdv/qenkIM9QFawRYLGJz07khj1BZO3MCkag3rnZQ=; b=ClwosYWbEO0MPXSrrxYlg8Y0OAlZPdvv4lZbVxVOXlj7MJbVA4Q5Gjr/WC6iRZXjqTiEtMr6RiycIKGKM2SzNVdvtEQyHEVBlt4D4kYaQ7NxCJWj8OzCZ9F6CQODGTWY0gcJm+eu48YqUwkhWzyDfHsKT4jT/yfJfbVDqc4aE+s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569410282706727.7718942657428; Wed, 25 Sep 2019 04:18:02 -0700 (PDT) Received: from localhost ([::1]:48274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5J3-0001hm-1g for importer@patchew.org; Wed, 25 Sep 2019 07:18:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44859) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58R-000831-1z for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58P-0004Tu-QA for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:02 -0400 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]:55102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3U0qLXQYKCgg0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iD58P-0004Sv-FM for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:01 -0400 Received: by mail-wr1-x44a.google.com with SMTP id z1so2172327wrw.21 for ; Wed, 25 Sep 2019 04:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7sLdv/qenkIM9QFawRYLGJz07khj1BZO3MCkag3rnZQ=; b=itCwXwjF4HKp1ICF6u3BN3A5+ZtwlWC6Eq2uxgit+woEDyX2oSLgiiK4vxSEDQslOI aXV3EkzwgzVG8QY8YVYqfbJoanaukt8YsfJnzmdrz2Ynm11oDdynnLgGyL4cVDuq2JQc b8fQfcsYto11MzGaezOWLcf46EbxRkg74VPLv0Imxig+fyvNyz6w80igSHKwU1Xx2yit D50lPa9P9K81uayNbNiyB7VZqClZhy3GLdmCHvXo4ZHOyF1EQrOxagMdy7M8AG+nGRLs UFiFczzfkAQu+qUePLob1YEV7yKM1UVhS4PU1am/rVQK2d/cq3x6wsOsKOkLjzEV4fX1 wKkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7sLdv/qenkIM9QFawRYLGJz07khj1BZO3MCkag3rnZQ=; b=Pwv8yCfxv7jAjBCNyVvKdoCbkk6CUum72gCeYRUwQke8bhLb06K+nLwWwsdlRkX2hT 0MsY72fdtYIxgmwQiUZ3P2HKocX7u4G7yo6XqCE5nAm2TqNNR2HUNPVH+nv8hLH84KlZ p/fl+HNP2lfeim5XXqK+gKjkLy2e4R1CK0XUsCoXsxtC6RY0HmkjHkFlY+gX8zjJJo+T kV8XmO4TjzznenULOJCV7/79HpOAUIfUCHpx7Lf3lDxPwYUU+RBBnccQfVweyng0obfz Ty3R87FotaQEJ+/3DsbvqpHXZAcCsX9NE1Ds6LVNhNmfY8ByLfr9vKWZ8jS3j9NpNN9J FFuQ== X-Gm-Message-State: APjAAAVwwGv/qxAqWu0z44axyBGGnNqXFdnPCzZezqxjmxocSJZxJAZJ y8Scf3iFc11coBXd/ylSXepxtr86ep0re2dKv8uoNjzw+VsUOqKSsaAgYSD3j3PO0pE2vjHZ+Kn Bi9wedbHuRXlAY1mDrYFXriVkDsDPhUK1fxylm+az2XCrvJ4R/swvVRz9oWvz X-Google-Smtp-Source: APXvYqwC2WZJOZmBBYlq0W2s0Z/KfuBqPF7r3H4ghdG6zJOxTM/8lCvcoKyM6HmFJYuBGAMAsGAOJ4UArDA= X-Received: by 2002:adf:ed88:: with SMTP id c8mr9195400wro.329.1569409619883; Wed, 25 Sep 2019 04:06:59 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:35 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-5-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 4/8] scsi: Propagate unrealize() callback to scsi-hd To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::44a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman We will need to add LCHS removal logic to scsi-hd's unrealize() in the next commit. Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/scsi-bus.c | 16 ++++++++++++++++ include/hw/scsi/scsi.h | 1 + 2 files changed, 17 insertions(+) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index bccb7cc4c6..359d50d6d0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -59,6 +59,14 @@ static void scsi_device_realize(SCSIDevice *s, Error **e= rrp) } } =20 +static void scsi_device_unrealize(SCSIDevice *s, Error **errp) +{ + SCSIDeviceClass *sc =3D SCSI_DEVICE_GET_CLASS(s); + if (sc->unrealize) { + sc->unrealize(s, errp); + } +} + int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private) { @@ -217,12 +225,20 @@ static void scsi_qdev_realize(DeviceState *qdev, Erro= r **errp) static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) { SCSIDevice *dev =3D SCSI_DEVICE(qdev); + Error *local_err =3D NULL; =20 if (dev->vmsentry) { qemu_del_vm_change_state_handler(dev->vmsentry); } =20 scsi_device_purge_requests(dev, SENSE_CODE(NO_SENSE)); + + scsi_device_unrealize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + blockdev_mark_auto_del(dev->conf.blk); } =20 diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index d77a92361b..332ef602f4 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -59,6 +59,7 @@ struct SCSIRequest { typedef struct SCSIDeviceClass { DeviceClass parent_class; void (*realize)(SCSIDevice *dev, Error **errp); + void (*unrealize)(SCSIDevice *dev, Error **errp); int (*parse_cdb)(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private); SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, uint32_t lun, --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569409806; cv=none; d=zoho.com; s=zohoarc; b=mBOUwYtMY9iesAuw+HYykBoohM+uvRT+3ho0pLS/dCR3OrNKIQesJeG/b42WCF96k+Wwg2ykZQYmjyl3QFWEOLLm+vrFf7OGC/0Az0YZPLb+EOgr8HGh+AlbLaFObYP8n3lHrqSPu/zeYceesoVblE0ZRJgbcVnOUEt1dldo74Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569409805; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ntmhuLh/qhZlaDmWWEGtABSx++pJ8zRHlQJB1iBCCeM=; b=UtpyfaC9o1IMexTY3hKUXYbzDvRE7JHx3+70o5x5xhAUNotEgKcOL1Pm5zhufXY2HAuNudm6EXAFop9pxvZH5SAZezSp5VwGJFPK07fZHCK5ITNCCGdvx6hMnpgq37mYlazzMrbccfPU00U1x5su2CJuZox+NvOP1FBusfkfYN0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569409805990160.87476303845574; Wed, 25 Sep 2019 04:10:05 -0700 (PDT) Received: from localhost ([::1]:48194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5BM-0001uc-KR for importer@patchew.org; Wed, 25 Sep 2019 07:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44878) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3WEqLXQYKCg05nzrvqt11tyr.p1z3rz7-qr8ry010t07.14t@flex--sameid.bounces.google.com>) id 1iD58U-000888-Tm for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3WEqLXQYKCg05nzrvqt11tyr.p1z3rz7-qr8ry010t07.14t@flex--sameid.bounces.google.com>) id 1iD58T-0004WF-Fx for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:06 -0400 Received: from mail-ua1-x94a.google.com ([2607:f8b0:4864:20::94a]:39687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3WEqLXQYKCg05nzrvqt11tyr.p1z3rz7-qr8ry010t07.14t@flex--sameid.bounces.google.com>) id 1iD58T-0004Vo-Bn for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:05 -0400 Received: by mail-ua1-x94a.google.com with SMTP id 93so921436uav.6 for ; Wed, 25 Sep 2019 04:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ntmhuLh/qhZlaDmWWEGtABSx++pJ8zRHlQJB1iBCCeM=; b=q/CdKGwK2P4ra3icnbeFpba2duuZbeziNYIlBj+Vfz2LnHK1YCNe5yqzkUQwWLgATF uG/jqgQEBJrvKzj3i0g1ixNc6vidFsENKXdJHQOTq27BvZ3zDBIyJQsy4++2BbMWsTNa 0YWytQ6Awb1sc7N2hu55ceLKE+VN9TQ6xM88gaqrW0CcgdL5WY7Nxp9ZBngMa7OfjxnD gD95B1ZsJayLzazoVyFAccyfJP/niv+1Ejjv46A9njNDgCQA2FacqYJCgc9PhZht5vph NVJV3grRPMuMqMtDerVYCL38VzQG3f+RGZdaf9eMfhapjLQUEIf7O0cRrKy6jo5nnxEh ZCew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ntmhuLh/qhZlaDmWWEGtABSx++pJ8zRHlQJB1iBCCeM=; b=uDg0POzC9QtuEOIsFHFIOrkXwianBLVh+uNcezBQgFwoW2Dn163Sk4mAWHBMob/DWy UqJF0kK6Ek9TGEQwkq/AAU6Y4Qh+HG2sOmD8oh0eVdXo8PiQA/espuksq71ZQzbeIYGD KXpAHTCjuv1KOJexM/GU64JVtMUflmWCS690IB3tiqOCC5Rp0FBiVeo1nbq5LfF4U6/F SdoyicETVjo9eqB9ojFoNgVonz0QrEMRQPeoL6J5O669GXz2MjIFH+Uo/iWZkHpBb85G 6r80T+daiwvpg2+pMc6+Rs/fdmKfijsTa7bgS0ex8ECphlyQB3DNmTYMxEuwZyhdD0Pi jhrQ== X-Gm-Message-State: APjAAAVBlexpsqAqFTBk8oxIyvpSY3rYKj1DPH+/Yf2hXDukjOUuB3m7 iwKn8kPmePuv9FiMYC/9nUeSwOczED7b1KpPfAc9UpvamkMiEthTFpzPeTsPa61iwYePAbG5hOo 0RFj5k/0UBAexd+jOV+Xp2OXOnA+dLFkzVDCNcOP9ytBp75wSgbRuqissGyNa X-Google-Smtp-Source: APXvYqwaOgOMNGzT7SpCpTtc42b1qzyS0/7xnmjCYyEE0vSlKawb/cT6s0tjvMgul/wpb0gYMJmUMncXhps= X-Received: by 2002:a1f:19d8:: with SMTP id 207mr2064708vkz.54.1569409624300; Wed, 25 Sep 2019 04:07:04 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:36 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-6-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 5/8] bootdevice: Gather LCHS from all relevant devices To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::94a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Relevant devices are: * ide-hd (and ide-cd, ide-drive) * scsi-hd (and scsi-cd, scsi-disk, scsi-block) * virtio-blk-pci We do not call del_boot_device_lchs() for ide-* since we don't need to - IDE block devices do not support unplugging. Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- hw/block/virtio-blk.c | 6 ++++++ hw/ide/qdev.c | 5 +++++ hw/scsi/scsi-disk.c | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 18851601cb..6d8ff34a16 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1186,6 +1186,11 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size); =20 blk_iostatus_enable(s->blk); + + add_boot_device_lchs(dev, "/disk@0,0", + conf->conf.lcyls, + conf->conf.lheads, + conf->conf.lsecs); } =20 static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) @@ -1193,6 +1198,7 @@ static void virtio_blk_device_unrealize(DeviceState *= dev, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOBlock *s =3D VIRTIO_BLK(dev); =20 + del_boot_device_lchs(dev, "/disk@0,0"); virtio_blk_data_plane_destroy(s->dataplane); s->dataplane =3D NULL; qemu_del_vm_change_state_handler(s->change); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6dd219944f..2ffd387a73 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -220,6 +220,11 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKin= d kind, Error **errp) =20 add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); + + add_boot_device_lchs(&dev->qdev, dev->unit ? "/disk@1" : "/disk@0", + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); } =20 static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *nam= e, diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 915641a0f1..d19896fe4d 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -35,6 +35,7 @@ #include "hw/block/block.h" #include "hw/qdev-properties.h" #include "sysemu/dma.h" +#include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "trace.h" =20 @@ -2402,6 +2403,16 @@ static void scsi_realize(SCSIDevice *dev, Error **er= rp) blk_set_guest_block_size(s->qdev.conf.blk, s->qdev.blocksize); =20 blk_iostatus_enable(s->qdev.conf.blk); + + add_boot_device_lchs(&dev->qdev, NULL, + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); +} + +static void scsi_unrealize(SCSIDevice *dev, Error **errp) +{ + del_boot_device_lchs(&dev->qdev, NULL); } =20 static void scsi_hd_realize(SCSIDevice *dev, Error **errp) @@ -3006,6 +3017,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, = void *data) SCSIDeviceClass *sc =3D SCSI_DEVICE_CLASS(klass); =20 sc->realize =3D scsi_hd_realize; + sc->unrealize =3D scsi_unrealize; sc->alloc_req =3D scsi_new_request; sc->unit_attention_reported =3D scsi_disk_unit_attention_reported; dc->desc =3D "virtual SCSI disk"; --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569410020; cv=none; d=zoho.com; s=zohoarc; b=mZfgz1uiIOGVQjG8B/52lSfZnglcZwE7GLgvDtCJy86kAh8QW6H40QWc/28BtN99G5o2E8mWk5vbkqWRZbYw1YmZOFxl2HjbiC23AhWgcbqLYpzKWrZPmiMbGS1N3skTIczm+wkN/+aN/+tdh67T3GgQ3bj5x9SmQepQw2yh7bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569410020; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=h+cRgKLkCqTFM58KGRf0r71ieDf+K2XSFGxiiABhRqM=; b=RUfzNzy6v0gBFj0F5++UCsmbj2ypNQGZ0PeDAcWl0cqbALO55HaOjksSihx+Go7XGTwY7A2CzZiPvWjIKBrww3sa6PLhIYtvkjk4kNoJAJJBFQE6+CD1ApoWW42Q9SxOaWoOUnW51J8bvZe+ZX1yfdDSffqxA1gDnv71M/wECho= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569410020143633.3681445526336; Wed, 25 Sep 2019 04:13:40 -0700 (PDT) Received: from localhost ([::1]:48228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5Eo-0006I3-GY for importer@patchew.org; Wed, 25 Sep 2019 07:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3XEqLXQYKChE9r3vzux55x2v.t537v3B-uvCv2454x4B.58x@flex--sameid.bounces.google.com>) id 1iD58d-0008Pu-Ng for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3XEqLXQYKChE9r3vzux55x2v.t537v3B-uvCv2454x4B.58x@flex--sameid.bounces.google.com>) id 1iD58Y-0004dg-KF for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:12 -0400 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]:40526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3XEqLXQYKChE9r3vzux55x2v.t537v3B-uvCv2454x4B.58x@flex--sameid.bounces.google.com>) id 1iD58Y-0004bR-DG for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:10 -0400 Received: by mail-wm1-x34a.google.com with SMTP id o188so1930292wmo.5 for ; Wed, 25 Sep 2019 04:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=h+cRgKLkCqTFM58KGRf0r71ieDf+K2XSFGxiiABhRqM=; b=sXBrOHw1PryXcsFrWUn6ZfAPoKJn/f+HCRNukLCAbqLVa9TPa6QWfKODNh0EB6gkja nIfWI2bPP5peuQuHZuJLHrihLLJSvHXXC5Ly5H8x6NAoaPJNj8xyiz3qIS9nnfMlKV13 a0L536sPYjmxSB1MzVORXjk1qQJVkeNIufCwksN8X5S77X4i6eMTI7cAM43cq9ZqX4pq aPnxjVbFQ49DGKY0WZOOw5CRVaK4kv+PF54V2r4TPyKv6RRqNW/ty5IVP2sn4ahKyGtc YXXsuYBE0zI27Wzs2Q3QztpXy7gvyU07jVhj0GrQEEyg8JsXMs6I9bkN/7GENTZwSEfR Esig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=h+cRgKLkCqTFM58KGRf0r71ieDf+K2XSFGxiiABhRqM=; b=VQ3NKzO1vRIljdtl4T7MiMEil/EfRjolYdvqZTJeKGMdOmzbeDRDrAgZHxSTVpt5H7 OPcymA5p/b+Z8V7ztWv/nJFXrSzIPvpgdUGBXLWhyh2EKRSAVEVCfgWUXpdEPkBkRBxb bW+Ii/3NGvs59Jx3o0kBkSyIwLDEgPBQsCYGHrNgiApl2s9wVWPcwP4flAW3sCOy6c7M dU0n/IOPk1ZZUxglv4mWQGrG5ilfTP+UiQ/fwMGV/0dXXVu21UUt+OtcMBa95TmwcDsf jczTJOg8PGjvx5Rg9e4Ie//8daHELqIGuUSQdRsFjIvFiC4/vJdTluGfTmgOOaGugqgL 9nBw== X-Gm-Message-State: APjAAAVsWwSGm2ryJpWuzsAqAf9T28gHJUQFIrjn4EgaxXiG7Qp3BLUY YzFHXAWMLhh9UnyJbplLoEpKhcYBg/4A4rBqme6OdeAryjzTJiQ8vICUpyqwo/JOR7jnZF0joB0 VKC2V7CscxJ3WpkO0CU5IiBTjJ3O2Za6wFzMKjBzAFXK++qvwfbBqK7Sp8bKF X-Google-Smtp-Source: APXvYqzDFfJYzGJTaE8CpmUSweSt5xnhDOIaD0TC6fugzWxHfnMzQdl/FZciG8WWkd4OIR2nR9Nv1dASbXI= X-Received: by 2002:a05:6000:1281:: with SMTP id f1mr176199wrx.247.1569409628619; Wed, 25 Sep 2019 04:07:08 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:37 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-7-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 6/8] bootdevice: Refactor get_boot_devices_list To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::34a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Move device name construction to a separate function. We will reuse this function in the following commit to pass logical CHS parameters through fw_cfg much like we currently pass bootindex. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- bootdevice.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index bc5e1c2de4..2b12fb85a4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -202,6 +202,39 @@ DeviceState *get_boot_device(uint32_t position) return res; } =20 +static char *get_boot_device_path(DeviceState *dev, bool ignore_suffixes, + char *suffix) +{ + char *devpath =3D NULL, *s =3D NULL, *d, *bootpath; + + if (dev) { + devpath =3D qdev_get_fw_dev_path(dev); + assert(devpath); + } + + if (!ignore_suffixes) { + if (dev) { + d =3D qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, d= ev); + if (d) { + assert(!suffix); + s =3D d; + } else { + s =3D g_strdup(suffix); + } + } else { + s =3D g_strdup(suffix); + } + } + + bootpath =3D g_strdup_printf("%s%s", + devpath ? devpath : "", + s ? s : ""); + g_free(devpath); + g_free(s); + + return bootpath; +} + /* * This function returns null terminated string that consist of new line * separated device paths. @@ -218,36 +251,10 @@ char *get_boot_devices_list(size_t *size) bool ignore_suffixes =3D mc->ignore_boot_device_suffixes; =20 QTAILQ_FOREACH(i, &fw_boot_order, link) { - char *devpath =3D NULL, *suffix =3D NULL; char *bootpath; - char *d; size_t len; =20 - if (i->dev) { - devpath =3D qdev_get_fw_dev_path(i->dev); - assert(devpath); - } - - if (!ignore_suffixes) { - if (i->dev) { - d =3D qdev_get_own_fw_dev_path_from_handler(i->dev->parent= _bus, - i->dev); - if (d) { - assert(!i->suffix); - suffix =3D d; - } else { - suffix =3D g_strdup(i->suffix); - } - } else { - suffix =3D g_strdup(i->suffix); - } - } - - bootpath =3D g_strdup_printf("%s%s", - devpath ? devpath : "", - suffix ? suffix : ""); - g_free(devpath); - g_free(suffix); + bootpath =3D get_boot_device_path(i->dev, ignore_suffixes, i->suff= ix); =20 if (total) { list[total-1] =3D '\n'; --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569409995; cv=none; d=zoho.com; s=zohoarc; b=nZOGrgIs0MDZi3xNfDxpm9j9yGhvxYiQASOhWyfnQ6RBLNRKzgX95kt1oCS0r27daxX0fruGa0dnXJadcee4na9Som+9K4ocGIP18ZSL7rHdQbdRDQqUnMVpkL7NxFHILHCAqfsrJdSWXkx+Uiyz9TAh33Z9CTrNJ+4boyTyTds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569409995; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=Z6j7SsyJ9mQMW4GGH8tlV5pWzxg6HSXU0oEHcFPQvQtFF3v20lLsXgviONcVBjVocUiXR9X7Dai0W9gib/dMarI9OYFuqrE9Je8gPtHD8bKLuevdoQ2T6Kamdn1NHvblThwY57aZel4Sg0oABP0Z8+NOnlajf0hjVMg/ULm1LwE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569409995361550.5269054263241; Wed, 25 Sep 2019 04:13:15 -0700 (PDT) Received: from localhost ([::1]:48224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5EI-0005r9-9F for importer@patchew.org; Wed, 25 Sep 2019 07:13:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44941) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58m-0000CQ-4x for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58i-0004j3-1a for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:22 -0400 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]:35830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58e-0004fD-GZ for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:17 -0400 Received: by mail-qt1-x84a.google.com with SMTP id x25so5496628qtq.2 for ; Wed, 25 Sep 2019 04:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=n0g6EcEhgtLT0NCcAphJmVIq2NP0HJepeKySY5GYfD6hoXKpSIZGzxBUv9bUCAbwB7 PzDQwJgk89Qo2mQC2cgnXps0zF9dySYAXXwq5+8tNUpkYuXRQlNio2NI1UkZzUEcLzJ4 x1Y+8xoOvEdRUi3LJ6EPuo7xAxG5PUjGUua7qqLDq0WZFcobwmgfMu/fdarDPKkEO785 kqJ4XlwPLVQfgX+ScTT+doh1IgMPr6Bmx3e6g1z3pyEoYxUX4g8+qmUcbN2PEXubdwov Sr5hJ9EA4PWrd4wNLnhTA5y57CoqMjwHEwV4K7oN5POnTg8KSEuXyxVeKxkUTiKqStOM Kk+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=gXeHN43HHRj6hftmdlOQCLJkMwj5avMkoUHkPX4GZu75yV+SXgm2NjZXE4gYhGJ0qk 7mGnMS4G37m10rSZ1d/fgznsmBuNTqq0csA0UZG82NRDD+197BUszGvfo5K3GmwhdiDY /FKPyt2hUxPimAZS3BiAKnYNqEPGFQv0MN9x3BJo7fTkA+M0yIKhLY4qgJbWw4IJ20Pm JdAoT9boi0K8Sa79LBWGhRx3O9WcivSFSj4J7l9M89EMUgYcqZRby9kF+PHf7gNi0Uxa ARsARadKyhGMjAGd/LIoOm53NxiVdmBo2NxlG3atwVHvyXtnw04RJIdU1xNoZF22Uu28 vZfw== X-Gm-Message-State: APjAAAVj1JdVWlBpWcxnOzd5yPJgsxs0cnmMP3ezVbGCSeI8jCBjs004 Mgu8oqPUZQcxWcO07ppvSAlx0V15Ng/sgoC1tnLMhWqwmjNtNK3DIUFtI3whHwdteXWK6zznTl1 XxWYuk9igrBhD9iG7Z3zXb6WyhiIoIIMgDBazYa84Yy+cdTMlkzZ0etABvfhQ X-Google-Smtp-Source: APXvYqw/4BvKzKbIF6sw8qGThdte8SI17nKVQUTMJ49lIMpcHBYNXkbbtZEFy+wcB0/aFY6//UfIkjhUCS0= X-Received: by 2002:a0c:8749:: with SMTP id 9mr6928386qvi.174.1569409632799; Wed, 25 Sep 2019 04:07:12 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:38 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-8-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 7/8] bootdevice: FW_CFG interface for LCHS values To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::84a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Using fw_cfg, supply logical CHS values directly from QEMU to the BIOS. Non-standard logical geometries break under QEMU. A virtual disk which contains an operating system which depends on logical geometries (consistent values being reported from BIOS INT13 AH=3D08) will most likely break under QEMU/SeaBIOS if it has non-standard logical geometries - for example 56 SPT (sectors per track). No matter what QEMU will report - SeaBIOS, for large enough disks - will use LBA translation, which will report 63 SPT instead. In addition we cannot force SeaBIOS to rely on physical geometries at all. A virtio-blk-pci virtual disk with 255 phyiscal heads cannot report more than 16 physical heads when moved to an IDE controller, since the ATA spec allows a maximum of 16 heads - this is an artifact of virtualization. By supplying the logical geometries directly we are able to support such "exotic" disks. We serialize this information in a similar way to the "bootorder" interface. The new fw_cfg entry is "bios-geometry". Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- bootdevice.c | 32 ++++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- include/sysemu/sysemu.h | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 2b12fb85a4..b034ad7bdc 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,35 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +/* Serialized as: (device name\0 + lchs struct) x devices */ +char *get_boot_devices_lchs_list(size_t *size) +{ + FWLCHSEntry *i; + size_t total =3D 0; + char *list =3D NULL; + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + char *chs_string; + size_t len; + + bootpath =3D get_boot_device_path(i->dev, false, i->suffix); + chs_string =3D g_strdup_printf("%s %" PRIu32 " %" PRIu32 " %" PRIu= 32, + bootpath, i->lcyls, i->lheads, i->lse= cs); + + if (total) { + list[total - 1] =3D '\n'; + } + len =3D strlen(chs_string) + 1; + list =3D g_realloc(list, total + len); + memcpy(&list[total], chs_string, len); + total +=3D len; + g_free(chs_string); + g_free(bootpath); + } + + *size =3D total; + + return list; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7dc3ac378e..18aff658c0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -920,13 +920,21 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *f= ilename, =20 static void fw_cfg_machine_reset(void *opaque) { + MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); + FWCfgState *s =3D opaque; void *ptr; size_t len; - FWCfgState *s =3D opaque; - char *bootindex =3D get_boot_devices_list(&len); + char *buf; =20 - ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); + buf =3D get_boot_devices_list(&len); + ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)buf, len); g_free(ptr); + + if (!mc->legacy_fw_cfg_order) { + buf =3D get_boot_devices_lchs_list(&len); + ptr =3D fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len= ); + g_free(ptr); + } } =20 static void fw_cfg_machine_ready(struct Notifier *n, void *data) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5bc5c79cbc..80c57fdc4e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -106,6 +106,7 @@ void validate_bootdevices(const char *devices, Error **= errp); void add_boot_device_lchs(DeviceState *dev, const char *suffix, uint32_t lcyls, uint32_t lheads, uint32_t lsecs); void del_boot_device_lchs(DeviceState *dev, const char *suffix); +char *get_boot_devices_lchs_list(size_t *size); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, --=20 2.23.0.351.gc4317032e6-goog From nobody Tue Apr 23 08:32:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569410001; cv=none; d=zoho.com; s=zohoarc; b=b2bYT5khwqPwFsC0kTljTP8ibyTQylXMXcQNZTBWvStS5x75eG0N0K/sESCFyzUX36n7C8n/NTSuXy8lC5gCHkabymynSNJ8iA1GoCXlRCVkpyLIrAPAhhi3nh5bS4VyW7octCixRuN4oTIYZ4nMIvNv3zDMUbx13tRJb+ZRlcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569410001; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=tJPQPnp7quie6wypwOLsgYCBbW9fpGkMsOAYlWhYyxA=; b=QWc1DukNmfvX12w3hycFGO+3KCjM/bf/5YjTrW2XRdsVSN99lP+IQHeKCqmF1BfQcitS1CFnSiy+2LqtBlJ46wvGKsrJcf4RHy9ioI5eKdJaoyN7ybUKd52ntgPbG8KOx2PjeCiahP2mRW6+Mj2M5EXWRgxMQCOZVR4L66eBgTQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569410001607761.3223526727647; Wed, 25 Sep 2019 04:13:21 -0700 (PDT) Received: from localhost ([::1]:48226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5ET-000635-TV for importer@patchew.org; Wed, 25 Sep 2019 07:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44973) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3ZEqLXQYKChkHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iD58s-0000LT-W0 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3ZEqLXQYKChkHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iD58m-0004lt-6N for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:28 -0400 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]:56238) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3ZEqLXQYKChkHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iD58k-0004ha-ER for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:24 -0400 Received: by mail-wr1-x449.google.com with SMTP id q10so2173222wro.22 for ; Wed, 25 Sep 2019 04:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tJPQPnp7quie6wypwOLsgYCBbW9fpGkMsOAYlWhYyxA=; b=ggFT6knRRHnqmfC7W4weuctHWhM9xRb3WFFOl1S2zOwU/cnVbqP3OrYyp22UiLg08m /HYcWwcuTkaXpWfNYXU7Jzos2AuT8moyXra2M/1GUEGi2gmM2ylagclQEFLy3vDWxpjx I6qoLoRdKafdG1VcwTNt4mdG+Fn9yXkc1msFSKfzjLAWesSZvus3yFMZTtqrOm19w5rR AmhlwvZrnc/qc/IJtdZUwFT3aRXkRs3HH6YdPlH9MbAMKYIk8LGcTegAZ5O/xb5uggQX PUvaFEGRkb/aGEQRzVs3pXpHNlJrbhzjbeMlMOXx/WdUpYTIBZWp6B8197IM98Dh4GHV cUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tJPQPnp7quie6wypwOLsgYCBbW9fpGkMsOAYlWhYyxA=; b=a/XAriZ+o40QbcPyK4sqsmjG5K5UDaUKg+8FZgUCtIUfoVexd4tawbQlJhsGHcFi8x KQkW8pRHJARtMLM9pb2em4rDvNDsBoEMV2Bu+tsiE+uspa0GMMKaL/08FIOLh5e1MFcn MoYrSmr/DliKmh9D+q5ZSygn6TuxTNMmrqyPIE4lhs38dcbwJr+IW1IRJXo+n7Rf2H/f RL6imiX31sRgnKSMVCGsOqB8K+t/L3X/wojdVK8ilrjhlb2+W5JT1ThI64FXezbZpTMm aayGwRjlkFqgfQEz+pGUaCpSIVFtPa+DG4kHHr/TUc6sseHnWhwn9z4sXCDtUafhQ/YX vs0A== X-Gm-Message-State: APjAAAVOVxajeBjuiiHdzrcnzsCI0jSwamAekpHKuxx/hb8/R/lkvf/p Jc7LQVDgTRwKpqcKP0sBk3asFTsWfJTM/1bJItqWmLAkVNFbr27ywyuq5zva7IdggRmVmVBJ0p9 d8MoZrsfn6ryVRgEwJs9NU2fmoUz1detovgeYvS23Mf2YE7fUb17qk5rAKTuF X-Google-Smtp-Source: APXvYqxS9/erVokFNjEvdGwlTmmkSNP8ugBCz6YcJ2cwt7K/X4m5xdswfM1OvpXtRBgrNsxLYc49Js6zVvY= X-Received: by 2002:a5d:428c:: with SMTP id k12mr9072654wrq.196.1569409636927; Wed, 25 Sep 2019 04:07:16 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:39 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-9-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 8/8] hd-geo-test: Add tests for lchs override To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::449 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add QTest tests to check the logical geometry override option. The tests in hd-geo-test are out of date - they only test IDE and do not test interesting MBRs. I added a few helper functions which will make adding more tests easier. QTest's fw_cfg helper functions support only legacy fw_cfg, so I had to read the new fw_cfg layout on my own. Creating qcow2 disks with specific size and MBR layout is currently unused - we only use a default empty MBR. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- tests/Makefile.include | 2 +- tests/hd-geo-test.c | 589 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 590 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 479664f899..a5b92fea6a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -780,7 +780,7 @@ tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-o= bj-y) tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) qemu-img$(E= XESUF) tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o -tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o +tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o $(libqos-obj-y) tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c index 62eb624726..458de99c31 100644 --- a/tests/hd-geo-test.c +++ b/tests/hd-geo-test.c @@ -17,7 +17,12 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/bswap.h" +#include "qapi/qmp/qlist.h" #include "libqtest.h" +#include "libqos/fw_cfg.h" +#include "libqos/libqos.h" +#include "standard-headers/linux/qemu_fw_cfg.h" =20 #define ARGV_SIZE 256 =20 @@ -388,6 +393,575 @@ static void test_ide_drive_cd_0(void) qtest_quit(qts); } =20 +typedef struct { + bool active; + uint32_t head; + uint32_t sector; + uint32_t cyl; + uint32_t end_head; + uint32_t end_sector; + uint32_t end_cyl; + uint32_t start_sect; + uint32_t nr_sects; +} MBRpartitions[4]; + +static MBRpartitions empty_mbr =3D { {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0} }; + +static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) +{ + const char *template =3D "/tmp/qtest.XXXXXX"; + char *raw_path =3D strdup(template); + char *qcow2_path =3D strdup(template); + char cmd[100 + 2 * PATH_MAX]; + uint8_t buf[512]; + int i, ret, fd, offset; + uint64_t qcow2_size =3D sectors * 512; + uint8_t status, parttype, head, sector, cyl; + char *qemu_img_path; + char *qemu_img_abs_path; + + offset =3D 0xbe; + + for (i =3D 0; i < 4; i++) { + status =3D mbr[i].active ? 0x80 : 0x00; + g_assert(mbr[i].head < 256); + g_assert(mbr[i].sector < 64); + g_assert(mbr[i].cyl < 1024); + head =3D mbr[i].head; + sector =3D mbr[i].sector + ((mbr[i].cyl & 0x300) >> 2); + cyl =3D mbr[i].cyl & 0xff; + + buf[offset + 0x0] =3D status; + buf[offset + 0x1] =3D head; + buf[offset + 0x2] =3D sector; + buf[offset + 0x3] =3D cyl; + + parttype =3D 0; + g_assert(mbr[i].end_head < 256); + g_assert(mbr[i].end_sector < 64); + g_assert(mbr[i].end_cyl < 1024); + head =3D mbr[i].end_head; + sector =3D mbr[i].end_sector + ((mbr[i].end_cyl & 0x300) >> 2); + cyl =3D mbr[i].end_cyl & 0xff; + + buf[offset + 0x4] =3D parttype; + buf[offset + 0x5] =3D head; + buf[offset + 0x6] =3D sector; + buf[offset + 0x7] =3D cyl; + + (*(uint32_t *)&buf[offset + 0x8]) =3D cpu_to_le32(mbr[i].start_sec= t); + (*(uint32_t *)&buf[offset + 0xc]) =3D cpu_to_le32(mbr[i].nr_sects); + + offset +=3D 0x10; + } + + fd =3D mkstemp(raw_path); + g_assert(fd); + close(fd); + + fd =3D open(raw_path, O_WRONLY); + g_assert(fd >=3D 0); + ret =3D write(fd, buf, sizeof(buf)); + g_assert(ret =3D=3D sizeof(buf)); + close(fd); + + fd =3D mkstemp(qcow2_path); + g_assert(fd); + close(fd); + + qemu_img_path =3D getenv("QTEST_QEMU_IMG"); + g_assert(qemu_img_path); + qemu_img_abs_path =3D realpath(qemu_img_path, NULL); + g_assert(qemu_img_abs_path); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s convert -f raw -O qcow2 %s %s > /dev/null", + qemu_img_abs_path, + raw_path, qcow2_path); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s resize %s %" PRIu64 " > /dev/null", + qemu_img_abs_path, + qcow2_path, qcow2_size); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + free(qemu_img_abs_path); + + unlink(raw_path); + free(raw_path); + + return qcow2_path; +} + +struct QemuCfgFile { + uint32_t size; /* file size */ + uint16_t select; /* write this to 0x510 to read it */ + uint16_t reserved; + char name[56]; +}; + +static uint16_t find_fw_cfg_file(QFWCFG *fw_cfg, + const char *filename) +{ + struct QemuCfgFile qfile; + uint32_t count, e; + uint16_t select; + + count =3D qfw_cfg_get_u32(fw_cfg, FW_CFG_FILE_DIR); + count =3D be32_to_cpu(count); + for (select =3D 0, e =3D 0; e < count; e++) { + qfw_cfg_read_data(fw_cfg, &qfile, sizeof(qfile)); + if (!strcmp(filename, qfile.name)) { + select =3D be16_to_cpu(qfile.select); + } + } + + return select; +} + +static void read_fw_cfg_file(QFWCFG *fw_cfg, + const char *filename, + void *data, + size_t len) +{ + uint16_t select =3D find_fw_cfg_file(fw_cfg, filename); + + g_assert(select); + + qfw_cfg_get(fw_cfg, select, data, len); +} + +#define BIOS_GEOMETRY_MAX_SIZE 10000 + +typedef struct { + uint32_t c; + uint32_t h; + uint32_t s; +} CHS; + +typedef struct { + const char *dev_path; + CHS chs; +} CHSResult; + +static void read_bootdevices(QFWCFG *fw_cfg, CHSResult expected[]) +{ + char *buf =3D g_malloc0(BIOS_GEOMETRY_MAX_SIZE); + char *cur; + GList *results =3D NULL, *cur_result; + CHSResult *r; + int i; + int res; + bool found; + + read_fw_cfg_file(fw_cfg, "bios-geometry", buf, BIOS_GEOMETRY_MAX_SIZE); + + for (cur =3D buf; *cur; cur++) { + if (*cur =3D=3D '\n') { + *cur =3D '\0'; + } + } + cur =3D buf; + + while (strlen(cur)) { + + r =3D g_malloc0(sizeof(*r)); + r->dev_path =3D g_malloc0(strlen(cur) + 1); + res =3D sscanf(cur, "%s %" PRIu32 " %" PRIu32 " %" PRIu32, + (char *)r->dev_path, + &(r->chs.c), &(r->chs.h), &(r->chs.s)); + + g_assert(res =3D=3D 4); + + results =3D g_list_prepend(results, r); + + cur +=3D strlen(cur) + 1; + } + + i =3D 0; + + while (expected[i].dev_path) { + found =3D false; + cur_result =3D results; + while (cur_result) { + r =3D cur_result->data; + if (!strcmp(r->dev_path, expected[i].dev_path) && + !memcmp(&(r->chs), &(expected[i].chs), sizeof(r->chs))) { + found =3D true; + break; + } + cur_result =3D g_list_next(cur_result); + } + g_assert(found); + g_free((char *)((CHSResult *)cur_result->data)->dev_path); + g_free(cur_result->data); + results =3D g_list_delete_link(results, cur_result); + i++; + } + + g_assert(results =3D=3D NULL); + + g_free(buf); +} + +#define MAX_DRIVES 30 + +typedef struct { + char **argv; + int argc; + char **drives; + int n_drives; + int n_scsi_disks; + int n_scsi_controllers; + int n_virtio_disks; +} TestArgs; + +static TestArgs *create_args(void) +{ + TestArgs *args =3D g_malloc0(sizeof(*args)); + args->argv =3D g_new0(char *, ARGV_SIZE); + args->argc =3D append_arg(args->argc, args->argv, + ARGV_SIZE, g_strdup("-nodefaults")); + args->drives =3D g_new0(char *, MAX_DRIVES); + return args; +} + +static void add_drive_with_mbr(TestArgs *args, + MBRpartitions mbr, uint64_t sectors) +{ + char *img_file_name; + char part[300]; + int ret; + + g_assert(args->n_drives < MAX_DRIVES); + + img_file_name =3D create_qcow2_with_mbr(mbr, sectors); + + args->drives[args->n_drives] =3D img_file_name; + ret =3D snprintf(part, sizeof(part), + "-drive file=3D%s,if=3Dnone,format=3Dqcow2,id=3Ddisk%d", + img_file_name, args->n_drives); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_drives++; +} + +static void add_ide_disk(TestArgs *args, + int drive_idx, int bus, int unit, int c, int h, i= nt s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device ide-hd,drive=3Ddisk%d,bus=3Dide.%d,unit=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + drive_idx, bus, unit, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); +} + +static void add_scsi_controller(TestArgs *args, + const char *type, + const char *bus, + int addr) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device %s,id=3Dscsi%d,bus=3D%s,addr=3D%d", + type, args->n_scsi_controllers, bus, addr); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_controllers++; +} + +static void add_scsi_disk(TestArgs *args, + int drive_idx, int bus, + int channel, int scsi_id, int lun, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device scsi-hd,id=3Dscsi-disk%d,drive=3Ddisk%d," + "bus=3Dscsi%d.0," + "channel=3D%d,scsi-id=3D%d,lun=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_scsi_disks, drive_idx, bus, channel, scsi_id, l= un, + c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_disks++; +} + +static void add_virtio_disk(TestArgs *args, + int drive_idx, const char *bus, int addr, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device virtio-blk-pci,id=3Dvirtio-disk%d," + "drive=3Ddisk%d,bus=3D%s,addr=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_virtio_disks, drive_idx, bus, addr, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_virtio_disks++; +} + +static void test_override(TestArgs *args, CHSResult expected[]) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + int i; + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + +static void test_override_ide(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/ide@1,1/drive@0/disk@0", {10000, 120, 30} }, + {"/pci@i0cf8/ide@1,1/drive@0/disk@1", {9000, 120, 30} }, + {"/pci@i0cf8/ide@1,1/drive@1/disk@0", {0, 1, 1} }, + {"/pci@i0cf8/ide@1,1/drive@1/disk@1", {1, 0, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_ide_disk(args, 0, 0, 0, 10000, 120, 30); + add_ide_disk(args, 1, 0, 1, 9000, 120, 30); + add_ide_disk(args, 2, 1, 0, 0, 1, 1); + add_ide_disk(args, 3, 1, 1, 1, 0, 0); + test_override(args, expected); +} + +static void test_override_scsi(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@1,0", {9000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@2,0", {1, 0, 0} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@3,0", {0, 1, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "lsi53c895a", "pci.0", 3); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30); + add_scsi_disk(args, 2, 0, 0, 2, 0, 1, 0, 0); + add_scsi_disk(args, 3, 0, 0, 3, 0, 0, 1, 0); + test_override(args, expected); +} + +static void test_override_scsi_2_controllers(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@1,0", {9000, 120, 30} }, + {"/pci@i0cf8/scsi@4/channel@0/disk@0,1", {1, 0, 0} }, + {"/pci@i0cf8/scsi@4/channel@0/disk@1,2", {0, 1, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "lsi53c895a", "pci.0", 3); + add_scsi_controller(args, "virtio-scsi-pci", "pci.0", 4); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30); + add_scsi_disk(args, 2, 1, 0, 0, 1, 1, 0, 0); + add_scsi_disk(args, 3, 1, 0, 1, 2, 0, 1, 0); + test_override(args, expected); +} + +static void test_override_virtio_blk(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@4/disk@0,0", {9000, 120, 30} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_virtio_disk(args, 0, "pci.0", 3, 10000, 120, 30); + add_virtio_disk(args, 1, "pci.0", 4, 9000, 120, 30); + test_override(args, expected); +} + +static void test_override_zero_chs(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_ide_disk(args, 0, 1, 1, 0, 0, 0); + test_override(args, expected); +} + +static void test_override_scsi_hot_unplug(void) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + QDict *response; + int i; + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@2/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@2/channel@0/disk@1,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + CHSResult expected2[] =3D { + {"/pci@i0cf8/scsi@2/channel@0/disk@1,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "virtio-scsi-pci", "pci.0", 2); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 20, 20, 20); + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qtest_qmp(qts, + "{ 'execute': 'device_del'," + " 'arguments': {'id': 'scsi-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qtest_qmp(qts, + "{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(qts, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + +static void test_override_virtio_hot_unplug(void) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + QDict *response; + int i; + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@2/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/disk@0,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + CHSResult expected2[] =3D { + {"/pci@i0cf8/scsi@3/disk@0,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_virtio_disk(args, 0, "pci.0", 2, 10000, 120, 30); + add_virtio_disk(args, 1, "pci.0", 3, 20, 20, 20); + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qtest_qmp(qts, + "{ 'execute': 'device_del'," + " 'arguments': {'id': 'virtio-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qtest_qmp(qts, + "{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(qts, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + int main(int argc, char **argv) { Backend i; @@ -413,6 +987,21 @@ int main(int argc, char **argv) qtest_add_func("hd-geo/ide/device/mbr/chs", test_ide_device_mbr_chs); qtest_add_func("hd-geo/ide/device/user/chs", test_ide_device_user_chs); qtest_add_func("hd-geo/ide/device/user/chst", test_ide_device_user_chs= t); + if (have_qemu_img()) { + qtest_add_func("hd-geo/override/ide", test_override_ide); + qtest_add_func("hd-geo/override/scsi", test_override_scsi); + qtest_add_func("hd-geo/override/scsi_2_controllers", + test_override_scsi_2_controllers); + qtest_add_func("hd-geo/override/virtio_blk", test_override_virtio_= blk); + qtest_add_func("hd-geo/override/zero_chs", test_override_zero_chs); + qtest_add_func("hd-geo/override/scsi_hot_unplug", + test_override_scsi_hot_unplug); + qtest_add_func("hd-geo/override/virtio_hot_unplug", + test_override_virtio_hot_unplug); + } else { + g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; " + "skipping hd-geo/override/* tests"); + } =20 ret =3D g_test_run(); =20 --=20 2.23.0.351.gc4317032e6-goog