From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244463; cv=none; d=zoho.com; s=zohoarc; b=dKl05Vak49GXyhicx6VpUdMevybe4m6x+JnJwuumAs75QvcAGAZN6ZgEmXOeRCOLgvzY1Rcw31gBVaqzIAJ+vFpTi9TY+cTDnJsPOqBoyWfMNuxABo7STc1f31MzuS3D+IrX3EZzHaaQHLzRyjxWGNB0iqh3XUcSds1ha6+d25Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244463; 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=tUHo9dKXhyv0Ca4PFpuClHGZsVjvVcITsBogQiKTl7s=; b=JOLXxIWX1cs2Kn3gtlPIMXgppGlKW1h56T4YaoUtNWjNUzJcLp2ks9PH/fBQXwYQ6wpQUlkuGvccHwVhOfjt2SQX57GPmAaSsUcF/FQCVmkbodJY+s3ZCsbJJr/MavmTG9jorIvMk479ClTsT27R8Ri63qHgCvRawX/tyXcBexI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244463353573.3064747198639; Wed, 16 Oct 2019 09:47:43 -0700 (PDT) Received: from localhost ([::1]:45608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmSb-0000Xo-7m for importer@patchew.org; Wed, 16 Oct 2019 12:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35972) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3VUinXQYKCnYmUgYcXaiiafY.WigkYgo-XYpYfhihaho.ila@flex--sameid.bounces.google.com>) id 1iKmN5-0003xf-Qq for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3VUinXQYKCnYmUgYcXaiiafY.WigkYgo-XYpYfhihaho.ila@flex--sameid.bounces.google.com>) id 1iKmN4-00064y-OV for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:41:59 -0400 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]:39272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3VUinXQYKCnYmUgYcXaiiafY.WigkYgo-XYpYfhihaho.ila@flex--sameid.bounces.google.com>) id 1iKmN4-00064m-Jp for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:41:58 -0400 Received: by mail-qk1-x749.google.com with SMTP id s3so24307864qkd.6 for ; Wed, 16 Oct 2019 09:41:58 -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:content-transfer-encoding; bh=tUHo9dKXhyv0Ca4PFpuClHGZsVjvVcITsBogQiKTl7s=; b=kNBJUPodP1ll0Cd/UCphX2etrl1SP/5V6r5bAQSM2+1v2kJnSqu8f+qx8xKv6NgYYn u4cV8AobEIK1Sl/6i4jPmd+zfWUwNgjygvl3PoxxE/n4355ShxaaimVSE53yhKHUGUAe aRIYfYBwEuUvfkq00Z780jRQ3hKQhL3rrAlg2pM+7fPCdU8gNYmz+qLl94DsdyFx7Ytg 12C743Laps1WJs+QMy3d19PbZJzpqnJfCLuUnFg17AMizBV8Kh9lKCgyUQr2ZPw1DYfq rkiQQTGMGcMh/afZM6/8OR912ThVfVjywFQ6qvEHTuR2Nnng7v10jT3JWReqZ1sNVf1z cvWA== 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:content-transfer-encoding; bh=tUHo9dKXhyv0Ca4PFpuClHGZsVjvVcITsBogQiKTl7s=; b=O3DkoPmMzPrvwbW979up3Ln4OPIyd92A9GWDlBmwkUXC7T5pR3s1Fjikzt/FQ9yE61 7vOTeztJNSJFsEDFQShbrqye+zkEZmN+gwhS0d0c1pCbbBGon4J08djq14n1cr3b3Ezm Bc1Vc8hdrSLPfCt0l1ZWZQOHg6WTPWbbnkwJMYVpD73a5hLjzI+h0cNQHmWRQxp7E7uD U5YfTzTcHUzmi+0HRk9PCWLL5lJB1gZUzVgJsTcYdS/tdR2orhzY+Gy000uW/G81KqQc yxPq7x34GrIYPMwRJBKAOZx2+x/3cJ6fJYYjSdbCMrkVXawk1pVpVeU7WVrX62Wna04P w1kA== X-Gm-Message-State: APjAAAXSQqJ6aaE7yLVQHlrtTGk67qhtwUCWswacuCf6NBIkWGyZwyOg RKmTlF0eD2M81YmPWQwnGl7L2kz+itoPw76xzXJKBgMJ2iavqMdT3s3Csw3yPjog88CWsgsRKkT SiNu8AX8By048j3cGRFTINpC79utZOnruo3WJmTgBqwNE1JYES8TZtNmSVyKW X-Google-Smtp-Source: APXvYqyksGp04TrBS5lTnT45E90skoPTjfr50ZI/PWPT6OSBog2AJR1+uoxuyR2fkqMDK0tQG7xj4lCQqX8= X-Received: by 2002:a05:620a:342:: with SMTP id t2mr41444675qkm.251.1571244117573; Wed, 16 Oct 2019 09:41:57 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:37 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-2-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 1/8] block: Refactor macros - fix tabbing From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::749 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Fixing tabbing in block related macros. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman --- 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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244298; cv=none; d=zoho.com; s=zohoarc; b=LDo+Ex5XkAqmh/cftJOpVFoYY9TmTDbpRUXs0EP9PBngM1xoxfvq1SAX5QWcKkNuQZR0G2KaduROwdN37rXYqqcsSLaKfluUEXcQHOg18WdT/+FeEfH9HtQb0uZqIIgIQmabon1vVvzSNJh5W8/1Ew6EzNlsVe3J21uNMk0XhHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244298; 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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=dtUneiLRCQn/fBjG2N6GiLD/e+sZ9U8E6agvFbjHmc0g24vf2mv6nmBxDB1iDAhr0p3e2HsJZvR+mj2pwRJicbeNeXf02mV+AZBNrYyJtuLsDiF7xWNXP/cHGPYtS9y2MIm87p+vMTT+hMw04CBAfflNPRxZrxIUGHKJT+RtaiM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244298142900.229696692936; Wed, 16 Oct 2019 09:44:58 -0700 (PDT) Received: from localhost ([::1]:45570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmPw-0006At-H7 for importer@patchew.org; Wed, 16 Oct 2019 12:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36059) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3WUinXQYKCnoqYkcgbemmejc.amkocks-bctcjlmlels.mpe@flex--sameid.bounces.google.com>) id 1iKmNE-000454-73 for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3WUinXQYKCnoqYkcgbemmejc.amkocks-bctcjlmlels.mpe@flex--sameid.bounces.google.com>) id 1iKmNB-000691-RA for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:08 -0400 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]:51567) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3WUinXQYKCnoqYkcgbemmejc.amkocks-bctcjlmlels.mpe@flex--sameid.bounces.google.com>) id 1iKmN9-00067j-Th for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:05 -0400 Received: by mail-wm1-x34a.google.com with SMTP id q22so1216133wmc.1 for ; Wed, 16 Oct 2019 09:42:03 -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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=N/8qU5HYH1WYYJIBE54zL08QXsZZeKZk6gMvSJqXPUFiZNeaswzbnLJk3lPdyA8iUD VQDR2frXBH9X99gSJkuU4akMAyZH8tZVT3vxLx36bdmAMYC6Hs0yx6SG0tLs9Pw9njzH GykNUeAzcduCUbCaUsnbL4y1lFhUg8ZmbHZA/2eAnpdO0IJ1Y+whXrDxe0RaIOLhz+gx hXbhuvRrTZq9jnzI0YDQl+jHFt6UiPV6GrvtCcvOh/05V6i9OqRCbvu7HKmDRm2LbRs5 TPN2uhHvAz1yc0vH9+qtKrN5eagzPwLEbSkTNdlWdreEgMiWYkzpYfZcmrctts2BPLKI g4eQ== 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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=MKnYECVwfDFk6qN35VF3PwHG+kpKIuEddgp/vsHzc8PtECBKGLNpxdSD7CWXUwFI1A tHUA7mIAdpLXiToJBv043G342lDy7NbBiDM41wFcxLJ9Zz318kMNeS2PltHPM6h1WzvH WuaDttf5SFbFBjiwQaGkjUz0tI4y5PFP+3VNsHW2WkPpwgYhv4FqKYjOmAZ/whrkl9qF yKu5pBXhF3IL59jzUcB/g9Sgkz2UcRhXbyPl6cix/NTuNAkQS9RgikrTxTLkm9u4z8VR 3+g+OF0eDaNwoHdJy+oXFx/dYXJ/88naFPBNVkvG4ZEnIW+YpcdTmhXd6ivbXTMY+6xU +geg== X-Gm-Message-State: APjAAAUBgtJEUy4vt6U1Epsp7apfXgVgcxjx+6k+Yhwe2vJlP2zaa9G5 9pOc8DQPy6X8YLPkgzNxfrUMPO3h93egzFveNlt03Ut5v/qiMFsEJOHK7HC3jkAcvjy6cQ2YjlW YiagmbW5zoIsxeFmiV5kCHv13Q42Er7sb2Dbl+ruh0xvXLcMJfP5ljh5cdlFQ X-Google-Smtp-Source: APXvYqzH2rPFYEAOseCg7wkEG1mJTdLmwqFMJvf2bGbEANA39+OU6T4wYLPGrz+d5I+L99LC2CYf9cUSzHc= X-Received: by 2002:adf:f0cc:: with SMTP id x12mr3568996wro.326.1571244121869; Wed, 16 Oct 2019 09:42:01 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:38 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-3-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 1/1] hd-geo-test: Add tests for lchs override From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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. 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 Signed-off-by: Sam Eiderman --- tests/Makefile.include | 2 +- tests/hd-geo-test.c | 551 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 552 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 3543451ed3..6941ae7c77 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..7e86c5416c 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,537 @@ 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; +} + +#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; + + qfw_cfg_get_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 +949,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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244284; cv=none; d=zoho.com; s=zohoarc; b=Jc4HC/kqmuWIptZkRy+bOBBpINrsEkG3jp/S1u+98Pr894GGh4fyc4DIaxR1gunrx+dPiS3iRa2Iip9gaeDHl6HFLFrlgPlEBstNaqsatbUZrm3pPdCEUi+PCirgVudHkBTv3UA9QkDQDDCu95cu/WkpdRib8k0NFxhGYqjHYXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244284; 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=E89nW/zbiaC6f3L/yPugJBT28Z9/vrZkYwI78yCPi60=; b=cif5KeeXIPTkNUYYdBfD400tP0zlipM7O2s3o0hgolbhKfWTo1dhnxAE0ZUKmhLyfkISwABH/TJnVI+4yc/c/oIBFmzX/BHkr7cARtCYd9gfEV/C+7AqkHKJxBy9py/JJrgikNCzeLVth9GSXhxUJdscYyUjuAs1GuNz23ew5Og= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244284055839.0040042403583; Wed, 16 Oct 2019 09:44:44 -0700 (PDT) Received: from localhost ([::1]:45568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmPi-0005tU-CH for importer@patchew.org; Wed, 16 Oct 2019 12:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36094) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3XkinXQYKCn8vdphlgjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--sameid.bounces.google.com>) id 1iKmNJ-00046T-HR for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3XkinXQYKCn8vdphlgjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--sameid.bounces.google.com>) id 1iKmNG-0006Br-Di for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:12 -0400 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]:38042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3XkinXQYKCn8vdphlgjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--sameid.bounces.google.com>) id 1iKmNG-0006AR-8E for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:10 -0400 Received: by mail-wr1-x449.google.com with SMTP id w10so11982175wrl.5 for ; Wed, 16 Oct 2019 09:42:08 -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=E89nW/zbiaC6f3L/yPugJBT28Z9/vrZkYwI78yCPi60=; b=p6zBUQjc9k6gj3CDXZkSUQ5JvLyGxIChJh4Mpo9LP2bgfxOMAHV/ztOb7BkU0t03/R ImaPiAUe7L924UIHUhjqo12iAsCPJyEHAspu6LboqA/vchCUHMeEZYmakj3zHLg230Y8 pC4z1b3If9pqmuUKa7ZwRDNtRfGhBnXySvjf9a5qkB3T7i9FrVnwuEkE3qFpSXWS7Lmh CExcW/kLe3ugbVWnvfRVClzEWHTRQ8sUV5xpbS127sCi4GR8XtQnZU12YGAc0FIC7pNb U5Mrn3qbmg2CwDAfYmg6aUN61qS/oiA5H3+VdGAaM5fowvSE+DGnD8oVN0OggBN59Vf2 w3nA== 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=E89nW/zbiaC6f3L/yPugJBT28Z9/vrZkYwI78yCPi60=; b=U4G+ZTGLUycasgfdYp0TiGJNMTSzCQYVgOEhi0TEGx+Z8wmVIre8EDBq9xHKijDL10 ONPVquejTdBq0jlep4UO82npmzrNZ+0wg2EmULspoGPo9LmT2cg/yHxGzSobnS19IpmF 0rzOfE6nfnLFqiHFRGmxYpJQZzeWpOTqdTHgjOXTvpIYc5AYXBktdkigQ+3Q/5Jpya3z XA7ep+BrzsILcuTlfwK7ZyvRby0GPFb+/sAWOA+JCYAYWsZr9wQUnOheLa9rSQS00gov AoayKfz9lhdODBD7sx8FaKln1XesDFWTSytnxg0rjTePHmIs7+VsPAcRTX1fro4Aub9H SnXQ== X-Gm-Message-State: APjAAAVP3Zs2wVZaaYUz2RXtqtg0oVjlsWCm8DmEbQIDwU46mBQXKsdN Ce4cnynEW+vl3jrjCqjdAwj4QkPY8Ta1KlfyCdJBEilyOGYHSECSGXvghwFJ277C974Rr7NiIyS uHT58O9DpwHZa67iyqKWFN/bnnqsCurhMLKwCYoHIzu2pveiBFANIPTQYr9sS X-Google-Smtp-Source: APXvYqxgbr+nQqZYUNNm+vaKrBek/8RPN3Tds3pAA81ahdVwc1CJd806LiBXJgLAUBq+2uPgByN+U8uxVpY= X-Received: by 2002:a5d:6685:: with SMTP id l5mr3412033wru.44.1571244126426; Wed, 16 Oct 2019 09:42:06 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:39 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-4-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 2/8] block: Support providing LCHS from user From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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 Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- 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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244359; cv=none; d=zoho.com; s=zohoarc; b=TIHEUwKauCGN1Sq/Dt7I7LDrX14HHGKW+xOTWN36GOMQ8T7JcqEmL9UIQVXAw3dM+eWFFhASvEyRREPuzcig0YBCC2bsSnwQoCoKO/R6qQnvd9R2/tXl39fIFnZn8PRlRp2ONIIMv3THiUXrzNU27aBvbrz374NYnzxgY2FMtIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244359; 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=Ba0ot1Tvsw4OGWynORYQWoMJh7SexhFWRbqwWG1oZNw=; b=c+kHVzTOtmQ/ImVT8LGUYse2ek4xxAZm08cL5drk/oFVL2OCePE11svhgFVC9lXTZLeGux7+R2WA+e17A4QvkePyEXsFbZj06C6VzEFGTT8JhvPv9CU5TXdCm/vUtD1T5y5UgByxBxBysqjOJXX8ttGRsTxyoPquVdgLxQcXVsg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244359253929.7050681806415; Wed, 16 Oct 2019 09:45:59 -0700 (PDT) Received: from localhost ([::1]:45582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmQv-0007MR-OV for importer@patchew.org; Wed, 16 Oct 2019 12:45:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36145) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3Y0inXQYKCoQ0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iKmNO-00048j-Ps for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3Y0inXQYKCoQ0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iKmNM-0006EG-LT for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:18 -0400 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]:56536) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3Y0inXQYKCoQ0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1iKmNK-0006Cb-Ke for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:15 -0400 Received: by mail-wr1-x44a.google.com with SMTP id s9so670171wrw.23 for ; Wed, 16 Oct 2019 09:42: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=Ba0ot1Tvsw4OGWynORYQWoMJh7SexhFWRbqwWG1oZNw=; b=A6PKUWsaQA7/TMzHltBbx9fkWsa8+71MiKRL5pFDVdgPpPq3kY+4/1Pi6L96IAWRDX lQZjKF073fVt6Wr8jju0W/iA1bqh2xVSgON1nUcCaMlhzmLC8ID+wFa9bmjcxcZHLFQg C2IVCr4WnEhf1K+lRjsrPXAdWJZpsw5u3EaZVsOaA6V5RjBcUASIwTW4HtQukhENZyrT 0z+33urIivKXn5wPBh/RIpqxkpDB9dSGYIuY/3f/FAM82GQTcahOgQInkmmt+jQ5Pl6g uzrwgCauAP3z7kL9d1gqx8RI4YdJyXndiJTuOvtrYb2snRDTwZcRyKZMw8yQEVK+JPYo Zk/w== 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=Ba0ot1Tvsw4OGWynORYQWoMJh7SexhFWRbqwWG1oZNw=; b=AbvVSBuST3SZJdumGsSSFomS20Io6SzC0vqcQS4ovbXqgvEE5PupVrLr3cisAKTEk0 UFj9kHVUYXuBZsLl/79VJjpwWH9dvzw3SM8tTYPm7HLhOGuBzCT2smSk58b1e4G3waiB /kWV0KWyh758aEvaL3oWJEq71PoQqXSi/R1K+zG05NB6myqvph8YQZUMe7NLtWRJsxEU jKHLF8rLsjTK7oS910c/69bCciQZt5xUappIuP1W/+RY0kEZ8zHRlQQ4EUbqrjrDe1Rl wFgUwQJzFvY9ANH1TnD71nX09Q3GuF9Th83NcXguEYJzehEQezrEP3OYpLy1pMrzWhlv 7zzA== X-Gm-Message-State: APjAAAWbnU3MOkCtSojrm2eEbf7uWn4Sa8Ieu8Fb7oEixp81b2AiQBxx VzpHt9AgNRnEFgL43MzHo3LEoTK1BpZ120bhH5A0T6naitiDhhmlxMZYYQC1exqYEqRGeusPdOn Uyi18jeg2b2pjfAKCDjmQ1RlkbPv4D4IWAScWm7xU+RStnDN5Xl+l3z30iVSo X-Google-Smtp-Source: APXvYqxjPOQ8OnAxBxoyfr61OmkNdNf0QPzoUpya4jxl5gOSh9eA3YLVY3k1IfzgnRLfTQMan9vt2FtVEck= X-Received: by 2002:a5d:6685:: with SMTP id l5mr3412366wru.44.1571244131837; Wed, 16 Oct 2019 09:42:11 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:40 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-5-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 3/8] bootdevice: Add interface to gather LCHS From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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 Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- 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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244503; cv=none; d=zoho.com; s=zohoarc; b=EdsGCIrxuKmPFT2M7iFYW0j8j0IWg8/Sl0gmFJ7SLqcwDjGBmrshFptu2hA877ipaX6wf3+a033kQIcEYr0dQHC9iXSHGLa2czjUO5Hr/ODe9NKiBXG6qx2WdCevnqw8BjuBdTT9Grj1xX8LO80zqlreu+e2F1q9ih5YYZ/s7VA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244503; 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=BN8bM2TtrG62TEO1U3a7nnR51CqBKCUhjF3qC5P9H3s=; b=YfLx5+9puNHgTMUww1Hcquxlf8qY3IUKYeIVoLESaPY9TojDJthR5GnMK42s02KqnuQtBYoX33BwwKT6aB44M7NFsNeFMBWoct5TZ2vZpWFomV+29iP1oEqao5rQtT7iJwEGvZ5tkCgRYOxoYT7Cczd+srLh3x97nstw2u+hbWs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 157124450318028.65009023815969; Wed, 16 Oct 2019 09:48:23 -0700 (PDT) Received: from localhost ([::1]:45618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmTF-00010l-S7 for importer@patchew.org; Wed, 16 Oct 2019 12:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3Z0inXQYKCog4myqups00sxq.o0y2qy6-pq7qxz0zsz6.03s@flex--sameid.bounces.google.com>) id 1iKmNQ-0004Bx-HQ for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3Z0inXQYKCog4myqups00sxq.o0y2qy6-pq7qxz0zsz6.03s@flex--sameid.bounces.google.com>) id 1iKmNP-0006Fc-Dp for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:20 -0400 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]:34843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3Z0inXQYKCog4myqups00sxq.o0y2qy6-pq7qxz0zsz6.03s@flex--sameid.bounces.google.com>) id 1iKmNP-0006E6-8a for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:19 -0400 Received: by mail-wr1-x44a.google.com with SMTP id 7so6732194wrl.2 for ; Wed, 16 Oct 2019 09:42:16 -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:content-transfer-encoding; bh=BN8bM2TtrG62TEO1U3a7nnR51CqBKCUhjF3qC5P9H3s=; b=NNTSbFdoRUGfMKEJDw9EuzjYhZYijB+c3FQgNPXYs3ZtdhZwu85gFLYRa03CSGJ60W e7lHOpj0VVKbMQQ7tAlUN16ppBLzSTyV5Tyz6x25fDIquCtTGpP7BQq7adzthVSzMOu4 X7I1wL80DJZwFWd1MmQSgMHYYvtBKiHwstCO1jph/nKKuuNpi0fgh/LLTjCtxtSxmGgh SG5gAYM5+SqkFwVfmnO2G+XsVeW4We+Cv1XDhX19OkdIdCE7JqWgb5l8fFL/FTCwdEo/ Q4XowSQ7IMDlEjgV+Dx714tuW35x3ICnpcAa4YFg7YytpEkze+3W4h0yiUm2maTzQquW 8Wvg== 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:content-transfer-encoding; bh=BN8bM2TtrG62TEO1U3a7nnR51CqBKCUhjF3qC5P9H3s=; b=lmzDe/94aoSKORQ7s7dvdbqMoh5qWnzUnrPM5lyMo0NzEpTAVLAzr0poWEHvSOl3yL d1tVFQKZJMCqlwmTOP0Bics22xFQbF0wZxT9KxDvZXOhihSoSET4NVGK8bmjoRBE22od OSL0KTvRQGgYYT7hrJZo7/wjE/mWJ7djj+2YNiUcu5QGx9sJ3ze7ZOgMVM/ZvyYyDjAZ N9RB0wcj3RY7ypklCay5BAKiLeNVUIvvlPi9xspMnqKZrTiwdp8oQXr3JxsKI0KVkrYm Hw6xj7GaB8nuxfeeOP5/6n2wiiHiorsqC5ZTATFmZBqyMdxtSt/nCqmumv8t2hbIYR/+ he3Q== X-Gm-Message-State: APjAAAVIqgGMmjGzDPRyeeW1An9phaDSCbpVgcM7gSdhxVIsIXnXL2AU Jk7R7Rj88vG8p8UD0hWucR3KL4UteB9yYHIfo2OyrUdKZXe6oXY3XH1Ul7xB+RhAvgvj76daeUe v4pUGsFtdZiwY9AfWonMvtPFg1UMEkZ1sn5eWTtXEBGCd32hRbxKUhwTTHHhY X-Google-Smtp-Source: APXvYqwusXB46n4F/NZK5qSsw7kyKmOfNyd4grdeACq22ZIaKZeYlgYtmL1oilBtQd05UPAR4YrT7LiCnPs= X-Received: by 2002:a5d:4285:: with SMTP id k5mr3500690wrq.344.1571244135793; Wed, 16 Oct 2019 09:42:15 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:41 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-6-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 4/8] scsi: Propagate unrealize() callback to scsi-hd From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman Content-Transfer-Encoding: quoted-printable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244858; cv=none; d=zoho.com; s=zohoarc; b=jdcHmf6SkgrFAsrl+SIclNDxOF02ubY1IKDKzVT7YpJEwl4kycAD5U0DRwEUG/Ts4H2V1KHAw4ukqmFcCDzcSKgwxU/my7qKydXQ3C1poT6Dmgc5Bgss6Ij9JS23yVVJZIRxaGQn1Kdk/88E5DM4TXlOlbE9cMZHjR5owEZRn60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244858; 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=jJrGsmisejq5BsmJhJyozl1VGOARUm605lXC7WQlSTg=; b=SW3MV0wJ30MMn13hsCueCBPqyn1m/hSO2ggOLQ+SdtyIsWDk9jwc3eAIKngPjYFmcfPiMY2Pq7rHxX1uCrm/Y+9B8RkQKXucZWPLjVyj06C+YaCQrq21sQB0vOavQAwBgtsFc9JvuBMarqOhy/62MH1R+SNOLgSmlQ19eY7wngY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244858293655.7479452160546; Wed, 16 Oct 2019 09:54:18 -0700 (PDT) Received: from localhost ([::1]:45672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmYz-0005oj-81 for importer@patchew.org; Wed, 16 Oct 2019 12:54:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36195) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3a0inXQYKCow8q2uytw44w1u.s426u2A-tuBu1343w3A.47w@flex--sameid.bounces.google.com>) id 1iKmNS-0004G3-MK for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3a0inXQYKCow8q2uytw44w1u.s426u2A-tuBu1343w3A.47w@flex--sameid.bounces.google.com>) id 1iKmNR-0006Gf-DD for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:22 -0400 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]:44629) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3a0inXQYKCow8q2uytw44w1u.s426u2A-tuBu1343w3A.47w@flex--sameid.bounces.google.com>) id 1iKmNR-0006GD-6e for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:21 -0400 Received: by mail-wr1-x449.google.com with SMTP id n18so11968366wro.11 for ; Wed, 16 Oct 2019 09:42:20 -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=jJrGsmisejq5BsmJhJyozl1VGOARUm605lXC7WQlSTg=; b=aHgoxQo67NIvAoSPLJkyoj+01YpH2YXalQ4j0UhVjNZahodZomhJ/keI6DhLY4qFwD Jvg2RmqryBx7dyzjgkpSqupqneWhrzQIGess1aTTh92aGpHzkrpKWHf7lmpu3GzCyrnV BkJSYNa4EKX3TWYntRA8T0gOZ3FaOTJp7m/J5cbOqBZKv1nSrbA9c9Pf7OGb0abZ1bo3 cw9+SzRw7eypvXl2W4rUjGVlVDd6RTF+0R890XAWTd1h1Ns8yAeRRbbOx6FoHpqMEykN GWGeTorSj2XZmFsJOEQvpsurkFwFAWD70u165hMqbizTEl3OiDEOJcBWXmg91v/sQESj NPuA== 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=jJrGsmisejq5BsmJhJyozl1VGOARUm605lXC7WQlSTg=; b=gDbjurDRZtI2sL+ccCnA+XSH3OIhQ97ikPrRdPDzWtEbREFZb5jaqBiBi90h85G1Km XtrDeKjyhuIyJ1JONdGsHlE60EGDa1eM480WnTE/sY3ro9SdCBmeMOP4BKYS8EgqZa+G 3UkLNrxu73eH9X45ewBe+TymmWdabKeRRQFZAbgdC0LIp3ybpgGHALI02C1VfOKwx2vv JQ694kfFwQ6yoOoXYYuC+OtVauUIp7yfs7NfqSd1CJJMvnCfUgqfZqEywQnAoVgSh8nN 6y4OLsTwV0bVCKBMyOf4jJr9zbLBAt+Az2suj1d4svttdBD9MZrRs5zCBqOEIjc5hhQO T3wA== X-Gm-Message-State: APjAAAUrhQe+LnO9YLdIAn43hhK0+wkKnH3H7lVh/i60U2mzUxlEiwtI SbWG/p4RKdUnaeOzKfJv98UfLf77xHQMma7huNOzmTRRm3R2nTlwkQPFTjH/VlaDehXwUvjZzWW 0fgImD7K3I7pzCewSzT6r42nGbIdk/CroV4FtUoj8br87CSxTUBSFfLc14lQr X-Google-Smtp-Source: APXvYqwkPk5TVkSLUX7xLsbZdrT7MnLsYXIq2aWqw8O3FzmohrA54NQSI9AF2ixkTUOWttMkSZgWPu9Fg1Y= X-Received: by 2002:adf:fcd2:: with SMTP id f18mr3847264wrs.388.1571244139969; Wed, 16 Oct 2019 09:42:19 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:42 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-7-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 5/8] bootdevice: Gather LCHS from all relevant devices From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- 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 ed2ddebd2b..c56e905f80 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1200,6 +1200,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) @@ -1207,6 +1212,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 68b1675fd9..07fb5ebdf1 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 @@ -2414,6 +2415,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) @@ -3018,6 +3029,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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244577; cv=none; d=zoho.com; s=zohoarc; b=TQk4D/+louZKhVyXHCjHtUlHy7ytVj2mJin9Q4+pa2dpRv9JtkcxfhzBWDuZ24gkPb73k+8JdU9ew4zgCwBOMlMi7iBhpmiiqOi3k/nNl7I7KjTALh6HO9TgYo4HYMR0Fvy98sEPObMbdHvS79n0/NoqbrfL0igUP+W3XKrqYJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244577; 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=JE4TuYAH1H5117bvmxHFP4bvJ+F5rdpnNADeRT4SBDM=; b=cnOaJhfFKGH7K4w8yfK09CvA8tdrKiouQNpxuMRwqTlaixl9Jqjfs0YrNAVXXsyqrVBd61hRDwvX+ok7GmPow1Dl910wOc/0Xw0S0KFyAXvhppKkW7YNsGbxtOJFGlNtcBB8cXhXwkzMKhFADC8AWsWRRQFbknYjQIwXk1JygIU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571244577985475.22909900855416; Wed, 16 Oct 2019 09:49:37 -0700 (PDT) Received: from localhost ([::1]:45626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmUS-0002Sb-4R for importer@patchew.org; Wed, 16 Oct 2019 12:49:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36253) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3cEinXQYKCpEDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iKmNW-0004NI-Jh for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3cEinXQYKCpEDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iKmNV-0006Ig-Aw for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:26 -0400 Received: from mail-vs1-xe49.google.com ([2607:f8b0:4864:20::e49]:36390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3cEinXQYKCpEDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iKmNV-0006IC-7g for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:25 -0400 Received: by mail-vs1-xe49.google.com with SMTP id z7so3192103vsz.3 for ; Wed, 16 Oct 2019 09:42:24 -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:content-transfer-encoding; bh=JE4TuYAH1H5117bvmxHFP4bvJ+F5rdpnNADeRT4SBDM=; b=rfmyUaMpv486XNrl+3+sf6XxsQlYuCyCyo8UD4552g9PMtcopqqh9iFis5oy+Il0gx kv8EXMY1GT1QrrAUbFc0DDR/6EBB4YW+thRmQSfkFTQ+3cg1mADpjUTkMCTF/1DN/WL0 0hjQgzOkbwnz3DrI7M9USmzR4kNCREdG1oo05XdyJo2pnYMbWfxELaZr9Pyf/rr7jyBk c4fsZO7BMNZtjoGygBnPt38Wh/3BxufpLRubsINQH+bE/Mnk7sZM4lCA9hkKJ1/bsKHz VoULjrjfZx1Pip0SIVGWnp+mOmSn9WDtICeGz/LQrVIuA5RDtpoD7KkjyK2V+XkYqNNh zSOQ== 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:content-transfer-encoding; bh=JE4TuYAH1H5117bvmxHFP4bvJ+F5rdpnNADeRT4SBDM=; b=q20OKRoeQIyZQMxy1Hy5xfrgXbxZ/Y14OtkWdITV1y0ukfaM25TrcSzCEHj4oFS8ML faDm6yAcddo9obNMjfzBpYJMQyMmtlTxYmUkTYkiDpdRCNb7F1FwxrN3Qm3HEM/gG286 TiGjSHD3zv0qgKnrK30MGveaIgiih8qZqOek7SUhdj71rC0YPRQsFji5dif5KS6Nxblh 96QQ+9wwvrYpCisLBNqE1d7beKmflf27z17Ak9UkHkGw5VCVnYbx3HDoJTpNxSEG134N 6q0p6NPUSrSuNJjCa3gW44bvPPD1B7T2cPG3jxtDYnrjcLYbkk3dkVp/2tOV8i6Banil d5cA== X-Gm-Message-State: APjAAAVZrjShYFL5UiJAJdxh6r2IIElF2Lmz6aEBJZHFqqJled+DyP1C U6i6xV816ti2AhlH4hPAjusOmnuEN9I/INFOkDV69992QXuxBDK/yaAg0Kc6aaCCPFY4grpOMC5 3FGt/IaqZ3b6r3dAZKmVKJv1ODjyq6HrBFYCNoiCpVvHh0ZypJ4C0Qyo5lYxI X-Google-Smtp-Source: APXvYqxWIJLOcgIpQjIyxeX6oyPPuJFlbQeIzcvA19EOw9sPnG83Dzx2lalfrneox6KN2fRKlXZqSthdOFM= X-Received: by 2002:a67:fa99:: with SMTP id f25mr1288594vsq.141.1571244144307; Wed, 16 Oct 2019 09:42:24 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:43 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-8-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 6/8] bootdevice: Refactor get_boot_devices_list From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::e49 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-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..2cf6b37c57 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, + const 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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571244949; cv=none; d=zoho.com; s=zohoarc; b=JAcFCX9ewfu8XoVTlIxFuTe4EBCWjCgmT30yOc9826DRoA57JSllPe79Xio1oYWlmvr1Mmrmt7kob+PzccoW8vtaZt+KnHg5mg7BXKVTLkozpi3Qm4mc1xvhgmkclQO7VwjEjhjeCoZ2PTWO2ProgV7xGlAUkWAFw/D7qKt4ToA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571244949; 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=NzlITaGA47lkkyjFV/anV49BZTCd68EIPlLQyW8+0JI=; b=F7ZzcnA/w8PRm+aGhiPibeeoctJXjboHxgxGg2VCbZdcrfrY617aiaQMYu7PsCLYN7ow3qrkAA9QhDd97QEbDRNOfuAR82nDiq83VqrZlHL59LkrFaRVVhq8tleInmvbXsAriAAjk7piM3toKwkBZHbyv9w09fWfdFGMq8lZ5Oo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571244949771477.3882221463973; Wed, 16 Oct 2019 09:55:49 -0700 (PDT) Received: from localhost ([::1]:45688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmaN-00075F-NI for importer@patchew.org; Wed, 16 Oct 2019 12:55:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36293) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3dEinXQYKCpUHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iKmNc-0004Vc-D5 for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3dEinXQYKCpUHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iKmNa-0006Kw-1c for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:32 -0400 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]:34844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3dEinXQYKCpUHzB3725DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--sameid.bounces.google.com>) id 1iKmNZ-0006KZ-RM for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:29 -0400 Received: by mail-wr1-x44a.google.com with SMTP id 7so6732407wrl.2 for ; Wed, 16 Oct 2019 09:42:29 -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:content-transfer-encoding; bh=NzlITaGA47lkkyjFV/anV49BZTCd68EIPlLQyW8+0JI=; b=lYICwWLXkb6KIuCOtCeNxC94Mpv+awURFjjLTDby1l56AvO3XNVJ9ZPUbFfjAF9p2X S45SrAAKKahrXOK06ABrfx+eRfevDNffJRXLoqfisYRVoP3zqJbdEUgYsA/RfhUf/IVC MSkkFNBBaM/9E8IyR0VseY/D0Mw4YkLiihPAbxAp7OYTvYWnaULs/ZfSakx39+pvRpuF l0vQcp/AXv9UbEunnTwx5paHHbnMpdndhenU0SY73tWJMDZ753aqXqDDkm58vVXyB1q0 L3ioQDMxCdFz3K35X7ytJ1L08cgoZ/GpaGXCFhLf8ZNSkp2AftFjTpk9bOd5I11CLT9f 6F/Q== 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:content-transfer-encoding; bh=NzlITaGA47lkkyjFV/anV49BZTCd68EIPlLQyW8+0JI=; b=J7G6es6t3ceBcC+WFuMJyKa5lnEHjG5JEIdvTVR1sPZeY9E0Nb8rnHLvBWLSI0KOOe Rg53VAaFmjKKfP2CGEJADSo507JksziPJH8sq7puwSwyQbpCcUlNijteYl0QBeAgHODB M3zLY2V1txusTmnAgLCstENZkxk0H30nv2H4UOR+r/vO9HLqqTt2KL71KK1y2snOJQAi cNtnB6UT8KLjMWWm4cMobgYhb/MOxxEiefCC/nMAjJ4kBMhMW4r2wMSH5g0ggwM5nuSE QXDMvfBPi7FR3F6a2SjnM3WOCu7fTYGcKK/UkMdaOugJcQb2ygr1x5BbnJ9Kq4JRFRjH hqcQ== X-Gm-Message-State: APjAAAUfsZmf/jJDKCgkSUALF1xh8b/RgyquU/nwnNf/hlaPH6iJNeDH hd8sZBxry+51p1mOtwbPSzLZxftZb4txjAIm/xP22P1LE9GxEoniIF1IBf9bwUZyNObEgpdlWGp yPrubx5B7SzIiTIF1+JaUzlxXx+Y9OFYk1rlvH5juECWX2q4dzgv5tNW/l8Eq X-Google-Smtp-Source: APXvYqxYHSsbeU/F/VCZ2FQbtYBNwoIuAVa/mgM7yjUhT6a+vWauNqm6sKOJGf05KmNpcuwE2Jv+GLlRKBk= X-Received: by 2002:a5d:4285:: with SMTP id k5mr3501381wrq.344.1571244148360; Wed, 16 Oct 2019 09:42:28 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:44 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-9-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 7/8] bootdevice: FW_CFG interface for LCHS values From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman Content-Transfer-Encoding: quoted-printable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-by: Philippe Mathieu-Daud=C3=A9 --- bootdevice.c | 31 +++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- include/sysemu/sysemu.h | 1 + 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 2cf6b37c57..03aaffcc8d 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,34 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +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.700.g56cf767bdb-goog From nobody Thu Apr 18 00:09:00 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=pass; 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1571245060; cv=none; d=zoho.com; s=zohoarc; b=ICZH8vhjrB2EGAnSsVeaO+cOA+v0OocMk9wxcUx+OX04/+MzaGbB+2DXNEljZBDsMTfnmiotsdOfJyhu4+ioah/7nderhsLPIG0u14lW0E6lIqAsbIchtBAzuDav0moHAB2AlHOihN1Ae81e+s7RE7F3f+XCHLWf+I5Tl+Qw1MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571245060; 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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=ZnF9YAKQYoVP4sT2aK/qCDIT+wa+xovVoDBag3gytRPDdcAYyz1j+IeoH4D/FPerJfENhuY8v1WJGS5XNVHR+TL9nDxi1PBa13Hva2DDo2YVpidtIihOiNQUffSN8tDGxIU4n1T/htTETV8EsFGv6pFPUBJQ/kwuaU91yNt60LA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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; dmarc=pass header.from= (p=reject 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 1571245060824702.244950641534; Wed, 16 Oct 2019 09:57:40 -0700 (PDT) Received: from localhost ([::1]:45708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmcF-0008DC-MD for importer@patchew.org; Wed, 16 Oct 2019 12:57:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36354) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3eEinXQYKCpkL3F7B69HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--sameid.bounces.google.com>) id 1iKmNh-0004dD-4y for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3eEinXQYKCpkL3F7B69HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--sameid.bounces.google.com>) id 1iKmNe-0006OJ-Ix for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:37 -0400 Received: from mail-ua1-x949.google.com ([2607:f8b0:4864:20::949]:50525) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3eEinXQYKCpkL3F7B69HH9E7.5HFJ7FN-67O7EGHG9GN.HK9@flex--sameid.bounces.google.com>) id 1iKmNe-0006NV-EU for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:42:34 -0400 Received: by mail-ua1-x949.google.com with SMTP id y4so5474159uaa.17 for ; Wed, 16 Oct 2019 09:42:33 -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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=jVqA+54POi4MJ+y5G5bFtF4SgBhDfQvLn6NBhMVLM6FotoH/edeOewb+vDAZHBrrxu ZuX8SGes3FfUyvnLg6D/dk2xNdK7BK7FhHjl1k8qabfRHRjrsh6ofcZS6zrYIkycyc2c TAhwDNSANGAUSJ+DheGVeT6knrZwELxHEBecz96/iiOdPNZv+dgNDEZoCsQHeAaKz7SZ RbJPaR6snCxR9JyFvTEqe1iBQo975Ugh2EeFAFFd0UKr3YubgvYS1KRMi7BopC/D5re/ xAoGKBP/w8YgRN77pPwt/pyjh1cQzXgqhg/QntLrcbeRniY6suzpiSBX2MusIY97T8Qj uIAw== 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=qE39xvt9M+c9HTM4QJYhh3xUrhI6EHqKxOejq8oTETM=; b=nI9Lo62PmsWuMRFoR4VzvtInnfuv7iZR2BvV1SG/Hi5CYZru/vIwFHX4OgsS+oQtDb +PADy+zubxrB9UBu3vdeX4GTX1On8qVjnD1mrckEt4cY0JEjPfhT4JH9H6ChsESLZvt7 nSAmATtT7UfKfM/rBoLNhcKQeKZ9w27R5NsHk2V9//yWxoyg3e9CJu1xY5dGVwIxS6z0 jI0UqtvWT1ZfR8b02gxXIgKBwR5M6/W0+4AcgX6YglImTvtm6+7iWTBFi0OqzGtxtrSA 5LfcDt91WMb/r3xEui3ngBneeXWVuewSACvfXXELptEBwVAaiuzptMLi+R2rvoeLrtJ1 UeDg== X-Gm-Message-State: APjAAAWEP1Y3JOOMS+SfJvD8fF+lFbbnhdpsSzCX8DtSQKg8q7bkztwb c8IE8IBYJclEjfV4ix/SA4xjXbidJq/swFk53zkWsl/D/WGNtD+M6UXlJ788hpZgKVRPLj68vSD 3/Pdc1jmBsSLOfL4FQvGfB16RNTgYd6YpSBIjU66srG66wo12tO+9oTLDb6mG X-Google-Smtp-Source: APXvYqz1IRUcu5bsMjufbC+5VO1oi0Z6VB1mbU/t7zl0J5ODQSiVVpxAPd2BFCX+tO9Snrtr/Jqnw3lp6w0= X-Received: by 2002:ab0:4a48:: with SMTP id r8mr19610506uae.62.1571244152649; Wed, 16 Oct 2019 09:42:32 -0700 (PDT) Date: Wed, 16 Oct 2019 19:41:45 +0300 In-Reply-To: <20191016164145.115898-1-sameid@google.com> Message-Id: <20191016164145.115898-10-sameid@google.com> Mime-Version: 1.0 References: <20191016164145.115898-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog Subject: [PATCH v8 8/8] hd-geo-test: Add tests for lchs override From: Sam Eiderman To: qemu-devel@nongnu.org Cc: arbel.moshe@oracle.com, karl.heubaum@oracle.com, kevin@koconnor.net, kraxel@redhat.com, kwolf@redhat.com, liran.alon@oracle.com, qemu-block@nongnu.org, sameid@google.com, seabios@seabios.org, lersek@redhat.com, philmd@redhat.com, jsnow@redhat.com, Sam Eiderman X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::949 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) 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. 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 Signed-off-by: Sam Eiderman --- tests/Makefile.include | 2 +- tests/hd-geo-test.c | 551 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 552 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 3543451ed3..6941ae7c77 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..7e86c5416c 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,537 @@ 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; +} + +#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; + + qfw_cfg_get_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 +949,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.700.g56cf767bdb-goog