From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894577; cv=none; d=zoho.com; s=zohoarc; b=YMZW2QEiJoF26DzSk1deFvnJ6k85sE0V2TMWfEC9um1SK6buETfblGXuLf4ZSO/4X92TSCqdBrzXzZqEF9N787FymPDr18zOmkzjB8+L4vbQ3KEPGWsaUyK9S8ksQzWfSTy06SI/OvkulsVhCEQcdVn5BcQgLyCMNJex4PSm4oA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894577; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=mnC+MT0EWE3I8fOBTcQ2N9AqdBzn+92Zu9jnhpTsMuE=; b=WYwiOh25Koxba0RGLkp+a8iTKnx3TRtB3FTphL/8XUgTy4D+UGi5tBJgSvVonazsx6xTttUdAjZg82ouSgetD28N0qWH9gcFqi9YMgr1GIqFMqMMCG3D/j/U/IBm8XJgeVVb3jyqllnnj4XlN2HsOodc0EO1cC72lINAKOxRw2E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894577491545.1479565782308; Tue, 27 Aug 2019 01:29:37 -0700 (PDT) Received: from localhost ([::1]:48102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2WrA-0001Dx-6o for importer@patchew.org; Tue, 27 Aug 2019 04:29:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36618) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <30OhkXQYKCicVDPHLGJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--sameid.bounces.google.com>) id 1i2WmY-0004cH-O4 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <30OhkXQYKCicVDPHLGJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--sameid.bounces.google.com>) id 1i2WmX-0007li-JP for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:50 -0400 Received: from mail-yw1-xc49.google.com ([2607:f8b0:4864:20::c49]:53639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <30OhkXQYKCicVDPHLGJRRJOH.FRPTHPX-GHYHOQRQJQX.RUJ@flex--sameid.bounces.google.com>) id 1i2WmX-0007lU-EO for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:49 -0400 Received: by mail-yw1-xc49.google.com with SMTP id c199so14467415ywb.20 for ; Tue, 27 Aug 2019 01:24:49 -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=mnC+MT0EWE3I8fOBTcQ2N9AqdBzn+92Zu9jnhpTsMuE=; b=DDwDhD0YXeUSFsn3sVNu1s5mqtuPZDRWp00A0WqIe54ydnAgjidn6NHQ6wfVXF4lR7 qy5XFJjXfSoVEBYNtqX11NUJ42TAdCEWU6QmnSR91uoAuIQxlw1m+P99pHxXYWz1CiPX ofaqwn3E7ZDLhjR9lbUhoolTXTwPww+bd4QAMkcsc8GOuGIMci1j7aQdYH4wGRW+V7QC Zqzp6NVtFHI1oRNnLibPEPegukvPMyNxWZAUis7bF/daQRqRzo49YjhLQgBUhQ7I2hPU ieIRGQl9XKDG/Gy+hUisHZqGdpP/vrH2sJpwz8xE8YpveE+WJrll/gxm2APmRxQ2d6Lk ieQw== 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=mnC+MT0EWE3I8fOBTcQ2N9AqdBzn+92Zu9jnhpTsMuE=; b=JJpqVylKUwaTZTFJGx0U1AS2+uv2PrQ4V1Q32jAVtwd0BKcUJCt4xaXsczDrMEwmuw fU4rMRTWHUHi4mYIvls/xNHhhO4Udi/hVJKdyhc9Kgit77lbh5GcSpetKmLrgsY27hQ7 NuNVbpaNXKk0gOkGvjoZWLfcehAiYTcYydsLnYvLSUsUNk1A5ukJS5KSMlTfGzRDkSCi JWJx8I+UYhjQQLomBI4zr9JakKb9ukQB4VN2yd98BsRbVAg7YDvnEETYosjPGii3REFQ +4oytM7fNS1Qr3oZ96ZY/cQ2GHcKSPrVSlukVUqwnKs6cI2Um5Gc0ROrXLV0v53/j5tN pw8w== X-Gm-Message-State: APjAAAU2+QJBipjiiY/+1tjpKIz7u1JBIwsigNJsa4DdfHnykkLmh3ys /0BqfbyEjyXdAHLxgX3BCyDE92XYOJzYI13FV/siS14rkOM+pUQehvP9aTn6ZF3VG0Yaoh6rJlM k7+qbIQIuOrXLIS5qnZa6ZPNQLE1IOvMpk5qD7gSqhKaoujWI67MuMYn2a+Cz X-Google-Smtp-Source: APXvYqzi8ekgmecfMPl2IqzfpRITXbSbqWc/XSUvBl6sfHg569OeKCapBtkMaAhRQX3Xj5AwjED0Uodh0vA= X-Received: by 2002:a25:768c:: with SMTP id r134mr15316699ybc.32.1566894288527; Tue, 27 Aug 2019 01:24:48 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:20 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-2-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c49 Subject: [Qemu-devel] [PATCH v6 1/8] block: Refactor macros - fix tabbing 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Fixing tabbing in block related macros. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- 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.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894749; cv=none; d=zoho.com; s=zohoarc; b=jmL8oU5jLDkxDUCRYqI37vPDvcCyNnZqr7/KR+Op4FHcIliVHzZzuwgLuKJrwkiv0l/kM/viSm5DBDKtiV+o7p4zFi1/gipCknODw6SxANr17TCmFlAjghxoneQ2hzsgf59EoxvCWpH4GQaGguYVB9QwqIiUbhlbu0G1L0uvr78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894749; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=FVd1PFIeVFll6+dyMcyTHlqBKcnOQa+GKOSlsKMvxhU=; b=I8FwLFZSuc0Oy9z28zWcPf4+KLWAnHIzGhKTUF1EYPK3+yc1Fu4B/4cYN8jChE8F6JoIfncHcscwZAd19MHK+3BMYqcdIoWKnRs95g0p5VjmSJf1Cu4X/GrDRw5eYSLXC3Sc3F0dzwVJl9nURVREbB4J5FIfHkqKiAKytKbcnCY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894749313726.2230768074984; Tue, 27 Aug 2019 01:32:29 -0700 (PDT) Received: from localhost ([::1]:48140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Wto-00046k-4f for importer@patchew.org; Tue, 27 Aug 2019 04:32:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36657) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <31OhkXQYKCisZHTLPKNVVNSL.JVTXLTb-KLcLSUVUNUb.VYN@flex--sameid.bounces.google.com>) id 1i2Wmd-0004j2-S4 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <31OhkXQYKCisZHTLPKNVVNSL.JVTXLTb-KLcLSUVUNUb.VYN@flex--sameid.bounces.google.com>) id 1i2Wmc-0007nQ-Q1 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:55 -0400 Received: from mail-vk1-xa4a.google.com ([2607:f8b0:4864:20::a4a]:48033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <31OhkXQYKCisZHTLPKNVVNSL.JVTXLTb-KLcLSUVUNUb.VYN@flex--sameid.bounces.google.com>) id 1i2Wmc-0007ms-Mb for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:54 -0400 Received: by mail-vk1-xa4a.google.com with SMTP id n185so8756041vkf.14 for ; Tue, 27 Aug 2019 01:24:53 -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=FVd1PFIeVFll6+dyMcyTHlqBKcnOQa+GKOSlsKMvxhU=; b=HWwmL1UpfDGN341vc1Zjy1tfdObT0V33VvW2TsMd7ql/ZA/CmN6gvnXr991eusT6r/ kq7bYSWuTFHaQdkdM6hUFAJVSqLCfTzIUDkg9IUbaj+JJH4MjkSP85HMQWzUPBXEOMRV nY0MaySOP4+DRRfbfYcvx6EpXDRnv8b/oNlI38w54q3RvdFb4ZsTxnmykr/HVWi2dK/D YfK7solvBt0XDwRY1Nkc/I9NvIgMEQB+jEkf6Ot/mpCjw9Jt4Rna2pQfgFhMMJsEM6Gx /VmyLnU8M/h2gxlVJAMpdoIAwl5pgA632HQG0BvAlj3apvxd7pLiwJE9VutJquSs08/r Hhog== 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=FVd1PFIeVFll6+dyMcyTHlqBKcnOQa+GKOSlsKMvxhU=; b=doKVsP7nwBNJXiQhT2iGIyA2FxevJDTnkoRsk1An82qxDzmN6gtI1APTWQpM18JIUE r2MARhdL2BSrI1ajd371+H3Gum7sFBjVJ8W0e18kVa2pxBJgOX4Zn5aF9ZKKIWzPXnyt n/QQTKXJN4+U7Oh5qOsRXN3YpcCQodWuqU/YsAdtJmIk16RcG8/O5IryZwH8fVTNbpLu wF2AJnqFv1W9Sysv56cLjq2axPLYn5ca1JfNUEB+HsB4Uw/ngi/qImqBYNNUjv4Mvm4R CI7K+x77PEZWNTCr6d8YqeaWfn75eRFO+xIEZzVkDn5C2ROB3REXqS44bP4Qi5Pik3QQ Rc7Q== X-Gm-Message-State: APjAAAXsAtW0AtgUdZ/2AmzcGmDpYHRJqMsmZmIw28BrFED4N34WOVn+ C2uAfkSveGvZw5+rfhlSlhQqOwcXOqpSFC22wezi/LvAh6VfttpACmkoDFMngdesR0hjYFEGItI DCgz1/W6S4+CDLpsRnkezkEWljA0XezZXYq00jiZqpqaKjZPBlvqmEvnh8cvG X-Google-Smtp-Source: APXvYqzoCKMgHI1WnRC/weBOvJdgtiFj95SoXzEqQaiYEW50PPzAw7Y/xt/6i/fxJNE2xikB86QsbFehTAw= X-Received: by 2002:a1f:b511:: with SMTP id e17mr9407857vkf.86.1566894292959; Tue, 27 Aug 2019 01:24:52 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:21 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-3-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::a4a Subject: [Qemu-devel] [PATCH v6 2/8] block: Support providing LCHS from user 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add logical geometry variables to BlockConf. A user can now supply "lcyls", "lheads" & "lsecs" for any HD device that supports CHS ("cyls", "heads", "secs"). These devices include: * ide-hd * scsi-hd * virtio-blk-pci In future commits we will use the provided LCHS and pass it to the BIOS through fw_cfg to be supplied using INT13 routines. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- 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.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894416; cv=none; d=zoho.com; s=zohoarc; b=V4erp2yOsicpCou8JR0ZVs3l2RgXEBPzoz41bDe8FG/3sS0f0QURmo5plypnLFgJ7G+4voexqAbQjg7SxzTq2eOuW/qkHsOAqQYAfuom3tPCoOPDzlN9gvBNXy19NMS5E3nGyQSNnZDTBOY4DA2FfhK4fBkuS6lUA3vZz8zvCGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894416; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=AHiYmk3G3VP6+xQ4SnXZuYPSma1xOEV081sAD4q4MI0=; b=Cc1mI0hfb3USmzEiZVqrO1kRuZwSWnshL4X4+iWiD0kcpWeh29uXoo96ej5fXIm6qV9OECC37a7Tfaanrg+8IXXMQDy7IGCuEmXLQDETdKKUcp8io9M38+RRrl5CngIVXthh9T5pKbGxJSVEFCa5o541UdCiooUTgI2MhLnZUDc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894415927165.04298201019697; Tue, 27 Aug 2019 01:26:55 -0700 (PDT) Received: from localhost ([::1]:48068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2WoT-0006Yr-N2 for importer@patchew.org; Tue, 27 Aug 2019 04:26:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36685) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <32ehkXQYKCjAeMYQUPSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--sameid.bounces.google.com>) id 1i2Wmi-0004pQ-4F for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <32ehkXQYKCjAeMYQUPSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--sameid.bounces.google.com>) id 1i2Wmg-0007p1-TR for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:00 -0400 Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]:42462) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <32ehkXQYKCjAeMYQUPSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--sameid.bounces.google.com>) id 1i2Wmg-0007oY-QB for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:24:58 -0400 Received: by mail-qk1-x74a.google.com with SMTP id b143so1759396qkg.9 for ; Tue, 27 Aug 2019 01:24: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; bh=AHiYmk3G3VP6+xQ4SnXZuYPSma1xOEV081sAD4q4MI0=; b=ZllCg2RbxXR9TfCTCXxBwylJghLBs/fqrOUInGlFuT6puckrSmNDjpAOYeCFzbGXL2 gTlPQCODIEePYi9iczsECP88pLiAydnerIqwL1oUHYSJJsXTokLKTIJ3356M3qlRImue 2y56ThB/Ou3M5+623fdKwbnr0evG17OlBMoJlzzCSyLEnUUr/7NcYqEQq5GExxXTwGlD sONueYEkgoKiuASkdVthnof8qvicd3Kpj0Rt8CUl70ZWx5U/YvGLJrfQU6G1CivB6Ea7 5pcssY7BtqOBiNC+Jrw2qtjrf3PwCItwshiV3qHrArcoFnNHo0cyYh/2qsjz9ky7xa6L 6icQ== 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=AHiYmk3G3VP6+xQ4SnXZuYPSma1xOEV081sAD4q4MI0=; b=hYEqrsf00bY6bZbA1IL6o9RvmXaqKpNNgHBaOBpuauaiLYq7cQYfVY9dxA0SYp6lGJ uhmpg9hFxISW0+dlSayf/2q/jHLXS4As1S/RZi30AOH1MqLOwM2gIec4HVxPnmxVdyWf o6pJOKZ9cojp/IKku0uqD3I+lZKtn3qhWZ7NpQJQRcjuGYqQUv+/0B+PQcOp1uqHTsI3 mYnUphfaXaqgJT1nI45mZHuMmqNbKMVX/HMzcLmy7F5dyJWQGjh0+H6SC8Zv0XC9oZ+M DtoPtbynnEEY/pk2sfDTZxbiHNgzChcs6WkMSjIa0isM2XZd5/z3PHvyw+jKbXcg2nyd 8pQA== X-Gm-Message-State: APjAAAXOEBKrh7VwmOlPBQ/aalTo43xwHtr6Dw1jej14c8JTibaGtK+e cV9CjFnmHf0qJW02MgCIuf5HKaE4RvnXxMANkBDuaq6xgrer/Tj5BankPCE+IYd86Zf07JS+y36 u3Rr2CnrkVnDD1e6IY8O58K64FIkFlsbg/CwSwCPqpfFttOalhkBDCXwKuoJC X-Google-Smtp-Source: APXvYqw/lGcoY5et+aEJyK9fWVS4bOPoXK/gMQDPOoxvDALF0GqY5FERAPOJPg36+xsn3NkKu/GeauDHMSw= X-Received: by 2002:a0c:eccf:: with SMTP id o15mr18214744qvq.15.1566894297664; Tue, 27 Aug 2019 01:24:57 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:22 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-4-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::74a Subject: [Qemu-devel] [PATCH v6 3/8] bootdevice: Add interface to gather LCHS 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add an interface to provide direct logical CHS values for boot devices. We will use this interface in the next commits. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- 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 d2c38f611a..1a33f25a5a 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -105,6 +105,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.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894596; cv=none; d=zoho.com; s=zohoarc; b=HFkPRj85ApW9ipgev+4hGtAB6DoSBIg25ut+6OtFmITIUsQ+riIuMN6wwWKBhAcbrZnKZm/uzxUsHhKx91v83V3lVnS7PAj1B8LX2tK8w1S/k7wEtLwd0DusTrLXbStbaev1C/37JFnBQ172fVYo4xqfL4dj5gEO9SkSEf/1P/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894596; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ouYipv769+h8e/fgBXMjwvu10/GoLSDxKV1jgFaYSYQ=; b=JKhdXME958BKyGj+npQTCfQAjfObPErDocA4obj3cwUZ6Lu2J+tAwgHqVtzJl/ALP1oWAi0avVk59LhGidufeuVOa5WibJQ+wen1etmH1hpox0kHAUkg5kyJNbjViQ5Vx4PIoxViW5kYxsc3nkEdVyv62aqu/MrjEBG59h+Sea4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894596081206.1185515384875; Tue, 27 Aug 2019 01:29:56 -0700 (PDT) Received: from localhost ([::1]:48106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2WrS-0001uU-QM for importer@patchew.org; Tue, 27 Aug 2019 04:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36729) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <33uhkXQYKCjUjRdVZUXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--sameid.bounces.google.com>) id 1i2Wmn-0004xm-5c for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <33uhkXQYKCjUjRdVZUXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--sameid.bounces.google.com>) id 1i2Wml-0007rJ-VI for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:05 -0400 Received: from mail-vs1-xe4a.google.com ([2607:f8b0:4864:20::e4a]:54520) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <33uhkXQYKCjUjRdVZUXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--sameid.bounces.google.com>) id 1i2Wml-0007qu-QM for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:03 -0400 Received: by mail-vs1-xe4a.google.com with SMTP id x20so4629511vsq.21 for ; Tue, 27 Aug 2019 01:25:02 -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=ouYipv769+h8e/fgBXMjwvu10/GoLSDxKV1jgFaYSYQ=; b=OZK5x3Fd1PnNWB8XFa6+t0GhQSAafiN3+wjVjpeVDi82xq4mw3BznjsdOwaui7Q7FU /lby9N/5iPWEcXuyRDwjzSf24JHG3nShNi3t6a1xTnwhRn5Bo+JCxcau9EgC5qVynjO2 kSprrOVI3zOMz/5UlkH/hEqKy0lBAfsAwLcrqb1+4tRv+4cKjo0l96sHSDQ6BW1eGexF Gdrs9e/Eyixb7Y+Z5ZgCSmL+MQW2ftfDTKT1xVGnd3s+FS3xL81htHf+ZkPFWPiG3Ch+ ner1i4lcC4B/2jKVkeK8sCdiCpDQTO1+FfvNZVG88pH6FJOS3ZKKtw5KcI3OU6Ac9C4A oC9g== 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=ouYipv769+h8e/fgBXMjwvu10/GoLSDxKV1jgFaYSYQ=; b=Y4pNhFJ1CssR22CG0xPHU8dw/IhU2YUAUJPEbVyATmORY6cIDzFtNwomvEU0UrelfI fcTL8NWTxVpQhdlSMD2nUBqg+/sLJ+pbGvOwqaYYZokQgEs/VKKqnLA7DoHBHrmcUmqt AlyemV8YBJ2AUBKUjo4229mNf1FyvpP7W7YsBE0cnGvFbo278GzWKvAi5xGQLYi3oM5I HBsfSGy+csCNKfy6BlxfPlGOxQMsQPfAkaZApFAmaTgneNf84Yl6tkdmguCO6jbeRpDY PlBG/rwdrNC+i0Sz/rBz1/S9xFVXsxZdN3Wj30GS3wsCPhjig2gaA3LaMOvjY4j0HVEW 7D+A== X-Gm-Message-State: APjAAAVLpnKwCIlHZwXNVCiDwfhp2h/lWjjpBcrM+WrgnSRO6Tr2bwF9 g+zIHwHf19cmJJCMO36iMa1eUKE3jXhtisUzk8kuArZOOCW1gSwhzW/34FHSqT1nblVXYBHmfYs KLhZ07HGVCwanvYF+Gj4rrmAr71csQJl7VDDiDLpEOKmyBWn7c6NxVEA/eIHI X-Google-Smtp-Source: APXvYqxJyxCreTVb4T4qwuVvr8uxbPKYUuU2j7I64MDeyOlT2mUoUzmHr++PAL4FJTRHEHXfj5RPdgjIiZk= X-Received: by 2002:ab0:73da:: with SMTP id m26mr10195338uaq.119.1566894302143; Tue, 27 Aug 2019 01:25:02 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:23 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-5-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::e4a Subject: [Qemu-devel] [PATCH v6 4/8] scsi: Propagate unrealize() callback to scsi-hd 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman We will need to add LCHS removal logic to scsi-hd's unrealize() in the next commit. Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- 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.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894425; cv=none; d=zoho.com; s=zohoarc; b=eGMIu8+ee3LQ81qIrj6wPS6dEB5VVq14AZ/OkTLfkCIPMsPje6XJ9YJVDoqkbeOFEepqmGH/NDewVefMYtITxbC6H9xSlESOOri1xZ0s5aMp6C/uSr0BrAMNRw8e4Q4wX7Q/cz3PPKCXQgXSnWql+M8AOonaFiIan/50piLFlA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894425; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=jN/yicpY7TigP5XcFMtmhHBGVv+suQiHAOiD2OyYqr4=; b=mHkxXbXe8zrbfBVhx8M3xzJZJRnRJaabV2W2LyJBcYLxGCk2Pqb40V/JCUagKR3TnhrRewOxfO2/eiqbShwSSZlBKagspqGUCrc+/hKDsy9xapZHdkGoYS1AfZpB9BBDeA4FcgxKqtfDqYOIhW3N7CCM8vD4VQLUn72eivbDp/Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894425068999.4295911283958; Tue, 27 Aug 2019 01:27:05 -0700 (PDT) Received: from localhost ([::1]:48078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Woh-0006td-Oy for importer@patchew.org; Tue, 27 Aug 2019 04:27:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <34uhkXQYKCjknVhZdYbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--sameid.bounces.google.com>) id 1i2Wmr-00054C-Qb for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <34uhkXQYKCjknVhZdYbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--sameid.bounces.google.com>) id 1i2Wmq-0007vf-96 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:09 -0400 Received: from mail-vk1-xa49.google.com ([2607:f8b0:4864:20::a49]:39635) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <34uhkXQYKCjknVhZdYbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--sameid.bounces.google.com>) id 1i2Wmq-0007u8-3o for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:08 -0400 Received: by mail-vk1-xa49.google.com with SMTP id f188so5261199vkh.6 for ; Tue, 27 Aug 2019 01:25:07 -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=jN/yicpY7TigP5XcFMtmhHBGVv+suQiHAOiD2OyYqr4=; b=IEuYGP1UzR9GmAOQvs6wszqOm67fQV5xbra/fTG6H9lBMIifIVR1AoVJqopc0NoDpp LNC2SDKS2H7nMwMmjNufMtMeAKW9+6wMv7PNl9PdaiYdtixHZRftwPPdxvJW7q6bcjNX PV0pBH6yPos+qkHTPE0y8BHsxo7g6V4UW4IZftlP0+vKXSCsoKudrMvHkJLxUUgjRqFe Q5JDz10s5qpR0ouAgOlsVtXBB9qvWsPvzTfLaq7GpseWN/FZzCqtk+mCjq3JPvKRFp2d tlW6YbVvammZjcYC949qch2kG5KiSUyyNUaHO79osO+ESmVwYYXOc0Vx1mmG3+czJB6E 3atg== 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=jN/yicpY7TigP5XcFMtmhHBGVv+suQiHAOiD2OyYqr4=; b=GgSFPQmdu5Q3C+zFAP/5Am+UmEgp5gmTZI79/Sune+AjhQ1EeWZ4mGqGyqHaT9SoP4 htmswMVce5+okXaNN5gHte1VrrNUftQm4EazGmjqULm7Zs/ByqYGN0G5e+9JHbF3YHHe mVaxbGNJD6RNnGP7vbv6rLhEflJbSNgZC74Us2YlcL55hgUMT7ehJDjPeXKJQaFB57CV lY8JfVm0PGKuEH4GZFv+pLpR2t5S79vVY5Vh9bM6lg0sExvYLfmkvCG1+YNAbozpkKym jdIIgbSFE/Xj6gmth9neCDM1OnoR2523emovIF7Ldj++7+rE/fZZ4aoHNLBY2iaslObw b4Cw== X-Gm-Message-State: APjAAAUksOfu50c8t28j5ZQhDeE/rJGxxSNdoIXPKXuUcD8C2TWRPAyJ vN1XeecMt/d9sl0krCfb8KLvXZkOTyvnRKu0DKqEXqiF6/yrb9b3028QwLh3kXpdZ6Ae3fQb/yG /NYCAKpnZJ+n+fUfFceX5KwSNNH2PsQO7C3dyn5xP2HHHLHJBm2InNpYLoWjD X-Google-Smtp-Source: APXvYqzAioivcnN3mUVRflxxjbKcHiHwkJ3YyF3OqEk6fCxi59fK3/wUm2jlkYxZDD1nV6F5iTtCZssGF3s= X-Received: by 2002:a67:f4ce:: with SMTP id s14mr1734968vsn.107.1566894306627; Tue, 27 Aug 2019 01:25:06 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:24 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-6-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::a49 Subject: [Qemu-devel] [PATCH v6 5/8] bootdevice: Gather LCHS from all relevant devices 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Relevant devices are: * ide-hd (and ide-cd, ide-drive) * scsi-hd (and scsi-cd, scsi-disk, scsi-block) * virtio-blk-pci We do not call del_boot_device_lchs() for ide-* since we don't need to - IDE block devices do not support unplugging. Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: John Snow Acked-by: Max Reitz --- hw/block/virtio-blk.c | 6 ++++++ hw/ide/qdev.c | 5 +++++ hw/scsi/scsi-disk.c | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 18851601cb..6d8ff34a16 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1186,6 +1186,11 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size); =20 blk_iostatus_enable(s->blk); + + add_boot_device_lchs(dev, "/disk@0,0", + conf->conf.lcyls, + conf->conf.lheads, + conf->conf.lsecs); } =20 static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) @@ -1193,6 +1198,7 @@ static void virtio_blk_device_unrealize(DeviceState *= dev, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOBlock *s =3D VIRTIO_BLK(dev); =20 + del_boot_device_lchs(dev, "/disk@0,0"); virtio_blk_data_plane_destroy(s->dataplane); s->dataplane =3D NULL; qemu_del_vm_change_state_handler(s->change); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6dd219944f..2ffd387a73 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -220,6 +220,11 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKin= d kind, Error **errp) =20 add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); + + add_boot_device_lchs(&dev->qdev, dev->unit ? "/disk@1" : "/disk@0", + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); } =20 static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *nam= e, diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 915641a0f1..d19896fe4d 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -35,6 +35,7 @@ #include "hw/block/block.h" #include "hw/qdev-properties.h" #include "sysemu/dma.h" +#include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "trace.h" =20 @@ -2402,6 +2403,16 @@ static void scsi_realize(SCSIDevice *dev, Error **er= rp) blk_set_guest_block_size(s->qdev.conf.blk, s->qdev.blocksize); =20 blk_iostatus_enable(s->qdev.conf.blk); + + add_boot_device_lchs(&dev->qdev, NULL, + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); +} + +static void scsi_unrealize(SCSIDevice *dev, Error **errp) +{ + del_boot_device_lchs(&dev->qdev, NULL); } =20 static void scsi_hd_realize(SCSIDevice *dev, Error **errp) @@ -3006,6 +3017,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, = void *data) SCSIDeviceClass *sc =3D SCSI_DEVICE_CLASS(klass); =20 sc->realize =3D scsi_hd_realize; + sc->unrealize =3D scsi_unrealize; sc->alloc_req =3D scsi_new_request; sc->unit_attention_reported =3D scsi_disk_unit_attention_reported; dc->desc =3D "virtual SCSI disk"; --=20 2.23.0.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894937; cv=none; d=zoho.com; s=zohoarc; b=Sm5vT2+CQ+Z2MjUuWgvIiCLb32DXtF1jLwyWljcHvqbhQYsYCraMm6fGraPGWuDlkpvPQBtIfeOd5AEheRQJ01gcpjfO383U+g4Y2qgqKvTSqvOzji+0Xdrc4wSXggVwkJaf6fLvGOh7mJIwAVRok5jptcNoDZi4+XcVhdrXR90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894937; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=RcOkFcAIGj6BGXdncuCfLnF9FQRUft0LS3RBiP/vPjdA4o7VmStleuIgM95RMh3BX/csDjkMmYZ4mCLAdkTwVQ5i9x/h+rf7WTCW4ild+K7m+t8qsLYqwF90kUwXyVPnr1o9yRtb+TTLxpZVP+STLfuDKTkx9kLoFBnk6HmXccs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894937372280.8924412265312; Tue, 27 Aug 2019 01:35:37 -0700 (PDT) Received: from localhost ([::1]:48166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Wwy-0006sC-Cv for importer@patchew.org; Tue, 27 Aug 2019 04:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36820) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmw-0005AP-4f for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmu-0007zl-KX for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:14 -0400 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]:32794) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmu-0007yO-Do for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:12 -0400 Received: by mail-qt1-x84a.google.com with SMTP id z4so7765747qts.0 for ; Tue, 27 Aug 2019 01:25:11 -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=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=CbKJAPw1MT/IBrPU8qQ6swEAaAYIdWjHRJRpRIcxJ3pOz34LIGk3RvyLDuz6Cizf7l HQwvZQOkaHTWmbmyY2frSZdUI43cLDiE7Xzr4xOviAgKRJaZtAlmEXtEPLNPhSsOxt4T 9d3q5+f7C2OyQ1BgCWrYQ8vFPX+ykhbt+osW/cCWKcI92i+4GT3bBGM+P/e9GJa/sNSt GgkBcoZg09Eoj4OxKtL42Clv/swGGz+hV3qvlNuCEuTr6jd0sIWyX0nWoP9yi28yMHPm dpTAdmOqu6dhiMqo56uP2lNHJp2i2xXig93spewf6Kv0i/aVct2kDh/RH+ugG5/EnZZ7 wv5w== 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=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=Yf5q6gRfOUkwNWzJ+F57y5PTd6QRN8mkHTW9+W31VJWFYt/EXGyqmw2Qb6bFICv8X9 Q79wRIegYpCRO2CSgh0I59g+ElYdNqGNE8+wJP9rPCLcyyIbO/bvEtWtK2fJ0xuq3Y4R 3Wm/DBuWrk7Cf1FLsacAcfHIK7Mi3nkWJ98XRssp2cIVcZb6q5Fpueof0WkpbKUFWFIV FP6a9aJDisiYvD4u4xYfxmBOdfNQ5gbca8OfR8jtnYkY7OzlAMEZ2ULRbWBYowLm6mm7 8mmDV9qZ2Lcnbw3sGZZHxfK6AXT4/NDDwO57KGbG/OYPATu/r5N9LiRnvz7u5iWQHRS/ /sBw== X-Gm-Message-State: APjAAAXz0f2U+1nWyJLMAK8BhGFZchS5stNz6sbjrVr+7Vy0hbxXdx4k eV4FIxapxjAzmJpUt39PnOY51p6MzfVwSMuX4xGJlyc/gA/I8r0Y7C1FT+OREx/0TwI8tJ1q4j8 8I06FhE3T8qR/zRxE1Jd845Iy0F9+Z5yWlPOMDNJZRqJAoPwbG3vqLLQbvdN5 X-Google-Smtp-Source: APXvYqzR2Bu5tguLmNI2OJs0vJYQdBPkgBFglYW047s6xn9s/pmimcdYPkN3v+UNZqcUaKuhGP9+ar6pLMg= X-Received: by 2002:a05:620a:16d6:: with SMTP id a22mr20275853qkn.414.1566894311112; Tue, 27 Aug 2019 01:25:11 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:25 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-7-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::84a Subject: [Qemu-devel] [PATCH v6 6/8] bootdevice: Refactor get_boot_devices_list 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Move device name construction to a separate function. We will reuse this function in the following commit to pass logical CHS parameters through fw_cfg much like we currently pass bootindex. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- bootdevice.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index bc5e1c2de4..2b12fb85a4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -202,6 +202,39 @@ DeviceState *get_boot_device(uint32_t position) return res; } =20 +static char *get_boot_device_path(DeviceState *dev, bool ignore_suffixes, + char *suffix) +{ + char *devpath =3D NULL, *s =3D NULL, *d, *bootpath; + + if (dev) { + devpath =3D qdev_get_fw_dev_path(dev); + assert(devpath); + } + + if (!ignore_suffixes) { + if (dev) { + d =3D qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, d= ev); + if (d) { + assert(!suffix); + s =3D d; + } else { + s =3D g_strdup(suffix); + } + } else { + s =3D g_strdup(suffix); + } + } + + bootpath =3D g_strdup_printf("%s%s", + devpath ? devpath : "", + s ? s : ""); + g_free(devpath); + g_free(s); + + return bootpath; +} + /* * This function returns null terminated string that consist of new line * separated device paths. @@ -218,36 +251,10 @@ char *get_boot_devices_list(size_t *size) bool ignore_suffixes =3D mc->ignore_boot_device_suffixes; =20 QTAILQ_FOREACH(i, &fw_boot_order, link) { - char *devpath =3D NULL, *suffix =3D NULL; char *bootpath; - char *d; size_t len; =20 - if (i->dev) { - devpath =3D qdev_get_fw_dev_path(i->dev); - assert(devpath); - } - - if (!ignore_suffixes) { - if (i->dev) { - d =3D qdev_get_own_fw_dev_path_from_handler(i->dev->parent= _bus, - i->dev); - if (d) { - assert(!i->suffix); - suffix =3D d; - } else { - suffix =3D g_strdup(i->suffix); - } - } else { - suffix =3D g_strdup(i->suffix); - } - } - - bootpath =3D g_strdup_printf("%s%s", - devpath ? devpath : "", - suffix ? suffix : ""); - g_free(devpath); - g_free(suffix); + bootpath =3D get_boot_device_path(i->dev, ignore_suffixes, i->suff= ix); =20 if (total) { list[total-1] =3D '\n'; --=20 2.23.0.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894439; cv=none; d=zoho.com; s=zohoarc; b=ipMFFQH3kG/jwpxiBZjhkO12POmg8VdWC2yWd9KkO7YTR2j/FkVsSU/8Dy0E+ltpqlsSLg/FpFxDR7UD6hpUpaM5ISLNbZwOzwag0/2ZEildH6y8ILPnU8PTWNHRYIW/zkG0n/1K1cgN9hX1sI8khfYUwNnN1aefCQ2qASvq5Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894439; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ReH46jE36OS5IMjEYP1C82QUib+jR1ntBNxmII/Xf2w=; b=gol1cvH5ammY6bPGfTRWR4QEFVHwxdjwFFfMViBuqmcYJ5B8voLHJnW2xW5qZRcjT7qK2gLhn3EQMXJ8Dt0LsueP0Xt+gCsIltGrbpmoLvPIJ/SCIidOJix8de0xMj0bZnBvzc8AFTQA5jbGRQVdvHeUbfMgMxv5V4YPcMll1mw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894439404798.836535869658; Tue, 27 Aug 2019 01:27:19 -0700 (PDT) Received: from localhost ([::1]:48080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Wov-0007BL-Pu for importer@patchew.org; Tue, 27 Aug 2019 04:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36841) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <36-hkXQYKCkIweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1i2Wn1-0005Ho-2r for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <36-hkXQYKCkIweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1i2Wmz-00084s-9R for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:18 -0400 Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]:46052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <36-hkXQYKCkIweqimhksskpi.gsquiqy-hiziprsrkry.svk@flex--sameid.bounces.google.com>) id 1i2Wmy-00082i-Qo for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:17 -0400 Received: by mail-qk1-x74a.google.com with SMTP id a197so18126387qkg.12 for ; Tue, 27 Aug 2019 01:25: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; bh=ReH46jE36OS5IMjEYP1C82QUib+jR1ntBNxmII/Xf2w=; b=LZkvzC86q7/0iRXlVUgcymRXHzd2tOI9NXY8eLpmMqGkjwV40MBfvYce3w9xKFTalw u+kCuEwQBfk8n4ECRTfuOIer8rXMT/VGkWuigLfGcBLoSNzP/xJ1uBlNyXRh6hDDM90B J7eU2J/pPDC3EUJNo0M/MJZ2ECXtgkmx54eFwU1pf5O9UdJIOakFIDbvqF4J7ahUDlBr 0DPklg0zcNHEsem1rWrB35y7kHPmdXMMLUgpDgG1QmjSzHatHoRpJiC8wx+8nvAWe8Vg QQO+9W8OUCKpwoJ8eDoOcR+l5Ds2LWiEdm5G/4S+cEJkt6xL2m8ME2obidLJrdjTJch8 rO0A== 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=ReH46jE36OS5IMjEYP1C82QUib+jR1ntBNxmII/Xf2w=; b=Zj7wHNpnmxKFBv51DWmvKgzg9ornkz+HC5v6gTSf+HETVokZ729eZV/vL7OXS6j7xh atmOsNAS1kfOeliMYHfJEIi6RjutG4sqyoJ2dc+zZdfVbYF4weyk+kfwopuGqzLKKwsH ZYpj02Ay4yyTqN9Zm9PdGc286zzbQPEK2vc4Np82HbxCBylUoYuDUq8RihdlZ8Z3Enwx l7Mou+sVmuzc4mptmr+oNwcE1HHRKRu1Vs0n9k/HerjrNAeP7qmklfQn1jDWCptct0HJ dga7+P+pirKPQOtnrL8uQaII2Y8KZF56OPGwIEib4ACLfEB++zXFySWLsTeRwbKdmDyV f+PQ== X-Gm-Message-State: APjAAAV4vi5Ow6Bo9yCG3K9iVp9z/+vIuruq/11RiNIaEn+CVUFigFzC 6AmU9FMsfaR3UR+skG8JKFa++3VaQRqDMbtEmofnVqSwQJNeaCLpTu0bwp9ExcgVh9hlY275q4H UpFNxPJrwZrw8ndCR9vU9cwVGaLK3nCWTiVs/cOu1OLZf/DDd64shBAIm3Q9C X-Google-Smtp-Source: APXvYqw2OeJvI73jn7V11ymInMcuJ1pjmcIFkJGE6ZDYgI5L1tzUJT5UvYgcKOSFFGHCHBCttsFwGqPuyeg= X-Received: by 2002:aed:3785:: with SMTP id j5mr21088892qtb.87.1566894315484; Tue, 27 Aug 2019 01:25:15 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:26 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-8-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::74a Subject: [Qemu-devel] [PATCH v6 7/8] bootdevice: FW_CFG interface for LCHS values 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Using fw_cfg, supply logical CHS values directly from QEMU to the BIOS. Non-standard logical geometries break under QEMU. A virtual disk which contains an operating system which depends on logical geometries (consistent values being reported from BIOS INT13 AH=3D08) will most likely break under QEMU/SeaBIOS if it has non-standard logical geometries - for example 56 SPT (sectors per track). No matter what QEMU will report - SeaBIOS, for large enough disks - will use LBA translation, which will report 63 SPT instead. In addition we cannot force SeaBIOS to rely on physical geometries at all. A virtio-blk-pci virtual disk with 255 phyiscal heads cannot report more than 16 physical heads when moved to an IDE controller, since the ATA spec allows a maximum of 16 heads - this is an artifact of virtualization. By supplying the logical geometries directly we are able to support such "exotic" disks. We serialize this information in a similar way to the "bootorder" interface. The new fw_cfg entry is "bios-geometry". Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- bootdevice.c | 32 ++++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- include/sysemu/sysemu.h | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 2b12fb85a4..b034ad7bdc 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,35 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +/* Serialized as: (device name\0 + lchs struct) x devices */ +char *get_boot_devices_lchs_list(size_t *size) +{ + FWLCHSEntry *i; + size_t total =3D 0; + char *list =3D NULL; + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + char *chs_string; + size_t len; + + bootpath =3D get_boot_device_path(i->dev, false, i->suffix); + chs_string =3D g_strdup_printf("%s %" PRIu32 " %" PRIu32 " %" PRIu= 32, + bootpath, i->lcyls, i->lheads, i->lse= cs); + + if (total) { + list[total - 1] =3D '\n'; + } + len =3D strlen(chs_string) + 1; + list =3D g_realloc(list, total + len); + memcpy(&list[total], chs_string, len); + total +=3D len; + g_free(chs_string); + g_free(bootpath); + } + + *size =3D total; + + return list; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7dc3ac378e..18aff658c0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -920,13 +920,21 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *f= ilename, =20 static void fw_cfg_machine_reset(void *opaque) { + MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); + FWCfgState *s =3D opaque; void *ptr; size_t len; - FWCfgState *s =3D opaque; - char *bootindex =3D get_boot_devices_list(&len); + char *buf; =20 - ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); + buf =3D get_boot_devices_list(&len); + ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)buf, len); g_free(ptr); + + if (!mc->legacy_fw_cfg_order) { + buf =3D get_boot_devices_lchs_list(&len); + ptr =3D fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len= ); + g_free(ptr); + } } =20 static void fw_cfg_machine_ready(struct Notifier *n, void *data) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 1a33f25a5a..150fe8c0e2 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -108,6 +108,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.187.g17f5b7556c-goog From nobody Fri Apr 26 09:23:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894602; cv=none; d=zoho.com; s=zohoarc; b=dIWGVz9Qdr7xFYraAklWm0Vu0FncTAgab+x1mVkUBCjkKyKlnrIDvDG1eMm8tGnvcj6In5wuNR3Wu1SrQF5fj7rAuRkEnHxl0P7UEio8bUms4Nd9XA1+0nGI9zWC4YkM4y4cDdB0RTXA23/VHTxKod4Jg+w8U7dLLuKMka6HTNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894602; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=3VknnNBz3wl1fOCX6Kfa2lBTFwci6b5anGXaxY85RIo=; b=fBLOWfdvke4mKMyN4+c8XN1I6JWe2naWYJdUnvvh4uvpERPpax9ArZ7W9oUHZf1Dzg90vF5tn2k1j2EGAXABrzMjPeheh8RZ1VlRgUzVIqSAesKevNcagxqgKLlUFAdPTSPXufgTDUeD6TZyeRLIBMi9erdHGYKtn2WiuLtJl7A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894602682703.9114782843833; Tue, 27 Aug 2019 01:30:02 -0700 (PDT) Received: from localhost ([::1]:48108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2WrZ-00024D-6n for importer@patchew.org; Tue, 27 Aug 2019 04:30:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36873) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <37-hkXQYKCkY0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1i2Wn8-0005Sy-3e for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <37-hkXQYKCkY0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1i2Wn3-0008BR-Ko for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:25 -0400 Received: from mail-yw1-xc4a.google.com ([2607:f8b0:4864:20::c4a]:49605) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <37-hkXQYKCkY0iumqlowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--sameid.bounces.google.com>) id 1i2Wn3-0008A9-Ai for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:21 -0400 Received: by mail-yw1-xc4a.google.com with SMTP id b195so14364670ywa.16 for ; Tue, 27 Aug 2019 01:25: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=3VknnNBz3wl1fOCX6Kfa2lBTFwci6b5anGXaxY85RIo=; b=PrT1U9NVOEU7EHeOhY260BhHlrpZ3IdHI0edZ9yjBsj6Med3Dfej2iysDRotFp3BPX ROHcp89OB8sAVt/53LOcW7Jnb74JWNgPZX+HlR4jucBc6Od6cYhN9kTr6+rWFrwIwkU1 T5zcnu6Leq/EjtQzldz2QY+RJs/Xc84azyKBbQotFKzP172tp4kA/neuUmwyM3Nf8Jpg qgRtY5UXMXngSSeTXDIb/LjIJtz75MUrvIoNh70+eZ/yFERrM4RFzrcrKnDlL+XZ8asn VAfBlxr6mzVjfbwUtWPGbccAd24z76iPtAxbb08eBpF3Mx73W+ilBoiUqz53bTlu+vwO wUcw== 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=3VknnNBz3wl1fOCX6Kfa2lBTFwci6b5anGXaxY85RIo=; b=K8oh/6rih87HWYfOIFNj48MpNcp9x8MNc9gse4bpxMdl8/eXKw8S56XBcmUhdl9V+G FdW7MZHaBCYx2InOJuajEmlSQzI6ABWnwG9aIqTm8aaGJ5HB/TaWPN9A/2VUoScE5ZGi z3F9k54+MJJkA0zJ6cuXlhWYLrABcTOYFKRguL15/YvO/FWYbcIMoqNY0lvPmfUVRXJZ 6LA9IZBdMnOgsyPMNxUFYh4l4dOvK6aN4zzXr9X7TZt5DmHWeRc4+oOCo1X/eevawvWn PVXcDRIUNfZypghEJ6eYnx+vzlL4PJ5wGXx3+eSrU8/5YjquNtcqerxpWIvJnWsqrPLO m5YA== X-Gm-Message-State: APjAAAWOz0hMxPOHjsbbLrV6jgMX+kQxt0mtYGb2B+kA5U1ZitzzPDey x0HGrPj0gTcZkvbcaF6EGnMm7peSgI95WXBkA50ecQRRZaXMC03dYq1gSNTdT9TKZXFXNSCbIhj 9HuoM9LXbX3u7gX0lu84R57uCc/EccWM1TedMGMUNg3ktSAqBHVoRrUQGB/jV X-Google-Smtp-Source: APXvYqzSkrI9g24bnCTZKdY+o9dK2v89nM+clRJswA3br8LfIIprFKQeKgrjP4bzLih9fT9+mpcxMHEsuMI= X-Received: by 2002:a0d:d616:: with SMTP id y22mr14890851ywd.365.1566894319951; Tue, 27 Aug 2019 01:25:19 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:27 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-9-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c4a Subject: [Qemu-devel] [PATCH v6 8/8] hd-geo-test: Add tests for lchs override 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add QTest tests to check the logical geometry override option. The tests in hd-geo-test are out of date - they only test IDE and do not test interesting MBRs. I added a few helper functions which will make adding more tests easier. QTest's fw_cfg helper functions support only legacy fw_cfg, so I had to read the new fw_cfg layout on my own. Creating qcow2 disks with specific size and MBR layout is currently unused - we only use a default empty MBR. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Acked-by: Max Reitz --- tests/Makefile.include | 2 +- tests/hd-geo-test.c | 582 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 583 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 39bed753b3..bd385e2150 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -781,7 +781,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..002f5c4a43 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,568 @@ static void test_ide_drive_cd_0(void) qtest_quit(qts); } =20 +typedef struct { + bool active; + uint32_t head; + uint32_t sector; + uint32_t cyl; + uint32_t end_head; + uint32_t end_sector; + uint32_t end_cyl; + uint32_t start_sect; + uint32_t nr_sects; +} MBRpartitions[4]; + +static MBRpartitions empty_mbr =3D { {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0} }; + +static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) +{ + const char *template =3D "/tmp/qtest.XXXXXX"; + char *raw_path =3D strdup(template); + char *qcow2_path =3D strdup(template); + char cmd[100 + 2 * PATH_MAX]; + uint8_t buf[512]; + int i, ret, fd, offset; + uint64_t qcow2_size =3D sectors * 512; + uint8_t status, parttype, head, sector, cyl; + char *qemu_img_path; + char *qemu_img_abs_path; + + offset =3D 0xbe; + + for (i =3D 0; i < 4; i++) { + status =3D mbr[i].active ? 0x80 : 0x00; + g_assert(mbr[i].head < 256); + g_assert(mbr[i].sector < 64); + g_assert(mbr[i].cyl < 1024); + head =3D mbr[i].head; + sector =3D mbr[i].sector + ((mbr[i].cyl & 0x300) >> 2); + cyl =3D mbr[i].cyl & 0xff; + + buf[offset + 0x0] =3D status; + buf[offset + 0x1] =3D head; + buf[offset + 0x2] =3D sector; + buf[offset + 0x3] =3D cyl; + + parttype =3D 0; + g_assert(mbr[i].end_head < 256); + g_assert(mbr[i].end_sector < 64); + g_assert(mbr[i].end_cyl < 1024); + head =3D mbr[i].end_head; + sector =3D mbr[i].end_sector + ((mbr[i].end_cyl & 0x300) >> 2); + cyl =3D mbr[i].end_cyl & 0xff; + + buf[offset + 0x4] =3D parttype; + buf[offset + 0x5] =3D head; + buf[offset + 0x6] =3D sector; + buf[offset + 0x7] =3D cyl; + + (*(uint32_t *)&buf[offset + 0x8]) =3D cpu_to_le32(mbr[i].start_sec= t); + (*(uint32_t *)&buf[offset + 0xc]) =3D cpu_to_le32(mbr[i].nr_sects); + + offset +=3D 0x10; + } + + fd =3D mkstemp(raw_path); + g_assert(fd); + close(fd); + + fd =3D open(raw_path, O_WRONLY); + g_assert(fd >=3D 0); + ret =3D write(fd, buf, sizeof(buf)); + g_assert(ret =3D=3D sizeof(buf)); + close(fd); + + fd =3D mkstemp(qcow2_path); + g_assert(fd); + close(fd); + + qemu_img_path =3D getenv("QTEST_QEMU_IMG"); + g_assert(qemu_img_path); + qemu_img_abs_path =3D realpath(qemu_img_path, NULL); + g_assert(qemu_img_abs_path); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s convert -f raw -O qcow2 %s %s > /dev/null", + qemu_img_abs_path, + raw_path, qcow2_path); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s resize %s %" PRIu64 " > /dev/null", + qemu_img_abs_path, + qcow2_path, qcow2_size); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + free(qemu_img_abs_path); + + unlink(raw_path); + free(raw_path); + + return qcow2_path; +} + +struct QemuCfgFile { + uint32_t size; /* file size */ + uint16_t select; /* write this to 0x510 to read it */ + uint16_t reserved; + char name[56]; +}; + +static uint16_t find_fw_cfg_file(QFWCFG *fw_cfg, + const char *filename) +{ + struct QemuCfgFile qfile; + uint32_t count, e; + uint16_t select; + + count =3D qfw_cfg_get_u32(fw_cfg, FW_CFG_FILE_DIR); + count =3D be32_to_cpu(count); + for (select =3D 0, e =3D 0; e < count; e++) { + qfw_cfg_read_data(fw_cfg, &qfile, sizeof(qfile)); + if (!strcmp(filename, qfile.name)) { + select =3D be16_to_cpu(qfile.select); + } + } + + return select; +} + +static void read_fw_cfg_file(QFWCFG *fw_cfg, + const char *filename, + void *data, + size_t len) +{ + uint16_t select =3D find_fw_cfg_file(fw_cfg, filename); + + g_assert(select); + + qfw_cfg_get(fw_cfg, select, data, len); +} + +#define BIOS_GEOMETRY_MAX_SIZE 10000 + +typedef struct { + uint32_t c; + uint32_t h; + uint32_t s; +} CHS; + +typedef struct { + const char *dev_path; + CHS chs; +} CHSResult; + +static void read_bootdevices(QFWCFG *fw_cfg, CHSResult expected[]) +{ + char *buf =3D g_malloc0(BIOS_GEOMETRY_MAX_SIZE); + char *cur; + GList *results =3D NULL, *cur_result; + CHSResult *r; + int i; + int res; + bool found; + + read_fw_cfg_file(fw_cfg, "bios-geometry", buf, BIOS_GEOMETRY_MAX_SIZE); + + for (cur =3D buf; *cur; cur++) { + if (*cur =3D=3D '\n') { + *cur =3D '\0'; + } + } + cur =3D buf; + + while (strlen(cur)) { + + r =3D g_malloc0(sizeof(*r)); + r->dev_path =3D g_malloc0(strlen(cur) + 1); + res =3D sscanf(cur, "%s %" PRIu32 " %" PRIu32 " %" PRIu32, + (char *)r->dev_path, + &(r->chs.c), &(r->chs.h), &(r->chs.s)); + + g_assert(res =3D=3D 4); + + results =3D g_list_prepend(results, r); + + cur +=3D strlen(cur) + 1; + } + + i =3D 0; + + while (expected[i].dev_path) { + found =3D false; + cur_result =3D results; + while (cur_result) { + r =3D cur_result->data; + if (!strcmp(r->dev_path, expected[i].dev_path) && + !memcmp(&(r->chs), &(expected[i].chs), sizeof(r->chs))) { + found =3D true; + break; + } + cur_result =3D g_list_next(cur_result); + } + g_assert(found); + g_free((char *)((CHSResult *)cur_result->data)->dev_path); + g_free(cur_result->data); + results =3D g_list_delete_link(results, cur_result); + i++; + } + + g_assert(results =3D=3D NULL); + + g_free(buf); +} + +#define MAX_DRIVES 30 + +typedef struct { + char **argv; + int argc; + char **drives; + int n_drives; + int n_scsi_disks; + int n_scsi_controllers; + int n_virtio_disks; +} TestArgs; + +static TestArgs *create_args(void) +{ + TestArgs *args =3D g_malloc0(sizeof(*args)); + args->argv =3D g_new0(char *, ARGV_SIZE); + args->argc =3D append_arg(args->argc, args->argv, + ARGV_SIZE, g_strdup("-nodefaults")); + args->drives =3D g_new0(char *, MAX_DRIVES); + return args; +} + +static void add_drive_with_mbr(TestArgs *args, + MBRpartitions mbr, uint64_t sectors) +{ + char *img_file_name; + char part[300]; + int ret; + + g_assert(args->n_drives < MAX_DRIVES); + + img_file_name =3D create_qcow2_with_mbr(mbr, sectors); + + args->drives[args->n_drives] =3D img_file_name; + ret =3D snprintf(part, sizeof(part), + "-drive file=3D%s,if=3Dnone,format=3Dqcow2,id=3Ddisk%d", + img_file_name, args->n_drives); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_drives++; +} + +static void add_ide_disk(TestArgs *args, + int drive_idx, int bus, int unit, int c, int h, i= nt s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device ide-hd,drive=3Ddisk%d,bus=3Dide.%d,unit=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + drive_idx, bus, unit, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); +} + +static void add_scsi_controller(TestArgs *args, + const char *type, + const char *bus, + int addr) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device %s,id=3Dscsi%d,bus=3D%s,addr=3D%d", + type, args->n_scsi_controllers, bus, addr); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_controllers++; +} + +static void add_scsi_disk(TestArgs *args, + int drive_idx, int bus, + int channel, int scsi_id, int lun, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device scsi-hd,id=3Dscsi-disk%d,drive=3Ddisk%d," + "bus=3Dscsi%d.0," + "channel=3D%d,scsi-id=3D%d,lun=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_scsi_disks, drive_idx, bus, channel, scsi_id, l= un, + c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_disks++; +} + +static void add_virtio_disk(TestArgs *args, + int drive_idx, const char *bus, int addr, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device virtio-blk-pci,id=3Dvirtio-disk%d," + "drive=3Ddisk%d,bus=3D%s,addr=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_virtio_disks, drive_idx, bus, addr, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_virtio_disks++; +} + +static void test_override(TestArgs *args, CHSResult expected[]) +{ + char *joined_args; + QFWCFG *fw_cfg; + int i; + + joined_args =3D g_strjoinv(" ", args->argv); + + qtest_start(joined_args); + fw_cfg =3D pc_fw_cfg_init(global_qtest); + + read_bootdevices(fw_cfg, expected); + + g_free(joined_args); + qtest_end(); + + 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) +{ + 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); + + qtest_start(joined_args); + fw_cfg =3D pc_fw_cfg_init(global_qtest); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qmp("{ 'execute': 'device_del'," + " 'arguments': {'id': 'scsi-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qmp("{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(global_qtest, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_end(); + + 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) +{ + 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); + + qtest_start(joined_args); + fw_cfg =3D pc_fw_cfg_init(global_qtest); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qmp("{ 'execute': 'device_del'," + " 'arguments': {'id': 'virtio-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qmp("{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(global_qtest, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_end(); + + 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 +980,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.187.g17f5b7556c-goog