From df2d925a27b75483b93dde1f4dd70cd3cbb7a48d Mon Sep 17 00:00:00 2001 From: Conghui Chen Date: Thu, 26 Apr 2018 03:29:48 +0800 Subject: [PATCH] DM: move boot device option 'b' just after emul The original code assume there is only one configuration for virtio-blk, and 'b' is just located after that configuration, so to get the value of 'b', it will end char *config by adding '\0' after the first configuration. Thus, char *config will change from: /XXXX_vdisk_file,range=xxx/xxx to: /XXXX_vdisk_file and char *b will point to: range=xxx/xxx So, the range will never take effect for virtio-blk. Now, 'b' is designed to located just after emul, and char *config will point to all configurations after 'b'. Note: only ",b," is taken for boot device option. Signed-off-by: Conghui Chen Reviewed-by: Yin Fengwei Reviewed-by: Hao Li Acked-by: Eddie Dong --- devicemodel/hw/pci/core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/devicemodel/hw/pci/core.c b/devicemodel/hw/pci/core.c index 9391248b4..1b7a7606b 100644 --- a/devicemodel/hw/pci/core.c +++ b/devicemodel/hw/pci/core.c @@ -181,10 +181,15 @@ pci_parse_slot(char *opt) if (cp != NULL) { *cp = '\0'; config = cp + 1; - cp = strchr(config, ','); - if (cp != NULL) { - *cp = '\0'; - b = cp + 1; + if (*config == 'b') { + b = config; + cp = config + 1; + if (*cp == ',') { + *cp = '\0'; + config = cp + 1; + } else { + b = NULL; + } } } } else {