While using SCSI passthrough, Following scenario makes qemu doesn't
realized the capacity change of remote scsi target:
1. online resize the scsi target.
2. issue 'rescan-scsi-bus.sh -s ...' in host.
3. issue 'rescan-scsi-bus.sh -s ...' in vm.
In above scenario I used to experienced errors while accessing the
additional disk space in vm. I think the reasonable operations should
be:
1. online resize the scsi target.
2. issue 'rescan-scsi-bus.sh -s ...' in host.
3. issue 'block_resize' via qmp to notify qemu.
4. issue 'rescan-scsi-bus.sh -s ...' in vm.
The errors disappear once I notify qemu by block_resize via qmp.
So this patch replaces the number of logical blocks of READ CAPACITY
response from scsi target by qemu's bs->total_sectors. If the user in
vm wants to access the additional disk space, The administrator of
host must notify qemu once resizeing the scsi target.
Bonus is that domblkinfo of libvirt can reflect the consistent capacity
information between host and vm in case of missing block_resize in qemu.
E.g:
...
<disk type='block' device='lun'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdc' index='1'/>
<backingStore/>
<target dev='sda' bus='scsi'/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
...
Before:
1. online resize the scsi target.
2. host:~ # rescan-scsi-bus.sh -s /dev/sdc
3. guest:~ # rescan-scsi-bus.sh -s /dev/sda
4 host:~ # virsh domblkinfo --domain $DOMAIN --human --device sda
Capacity: 4.000 GiB
Allocation: 0.000 B
Physical: 8.000 GiB
5. guest:~ # lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
└─sda1 8:1 0 2G 0 part
After:
1. online resize the scsi target.
2. host:~ # rescan-scsi-bus.sh -s /dev/sdc
3. guest:~ # rescan-scsi-bus.sh -s /dev/sda
4 host:~ # virsh domblkinfo --domain $DOMAIN --human --device sda
Capacity: 4.000 GiB
Allocation: 0.000 B
Physical: 8.000 GiB
5. guest:~ # lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 4G 0 disk
└─sda1 8:1 0 2G 0 part
References: [SUSE-JIRA] (SLE-20965)
Signed-off-by: Lin Ma <lma@suse.com>
93 lines
3.3 KiB
C
93 lines
3.3 KiB
C
/*
|
|
* QEMU block throttling group infrastructure
|
|
*
|
|
* Copyright (C) Nodalink, EURL. 2014
|
|
* Copyright (C) Igalia, S.L. 2015
|
|
*
|
|
* Authors:
|
|
* Benoît Canet <benoit.canet@nodalink.com>
|
|
* Alberto Garcia <berto@igalia.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 or
|
|
* (at your option) version 3 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef THROTTLE_GROUPS_H
|
|
#define THROTTLE_GROUPS_H
|
|
|
|
#include "qemu/coroutine.h"
|
|
#include "qemu/throttle.h"
|
|
#include "block/block_int.h"
|
|
#include "qom/object.h"
|
|
|
|
/* The ThrottleGroupMember structure indicates membership in a ThrottleGroup
|
|
* and holds related data.
|
|
*/
|
|
|
|
typedef struct ThrottleGroupMember {
|
|
AioContext *aio_context;
|
|
/* throttled_reqs_lock protects the CoQueues for throttled requests. */
|
|
CoMutex throttled_reqs_lock;
|
|
CoQueue throttled_reqs[THROTTLE_MAX];
|
|
|
|
/* Nonzero if the I/O limits are currently being ignored; generally
|
|
* it is zero. Accessed with atomic operations.
|
|
*/
|
|
unsigned int io_limits_disabled;
|
|
|
|
/* Number of pending throttle_group_restart_queue_entry() coroutines.
|
|
* Accessed with atomic operations.
|
|
*/
|
|
unsigned int restart_pending;
|
|
|
|
/* The following fields are protected by the ThrottleGroup lock.
|
|
* See the ThrottleGroup documentation for details.
|
|
* throttle_state tells us if I/O limits are configured. */
|
|
ThrottleState *throttle_state;
|
|
ThrottleTimers throttle_timers;
|
|
unsigned pending_reqs[THROTTLE_MAX];
|
|
QLIST_ENTRY(ThrottleGroupMember) round_robin;
|
|
|
|
} ThrottleGroupMember;
|
|
|
|
#define TYPE_THROTTLE_GROUP "throttle-group"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(ThrottleGroup, THROTTLE_GROUP)
|
|
|
|
const char *throttle_group_get_name(ThrottleGroupMember *tgm);
|
|
|
|
ThrottleState *throttle_group_incref(const char *name);
|
|
void throttle_group_unref(ThrottleState *ts);
|
|
|
|
void throttle_group_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg);
|
|
void throttle_group_get_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg);
|
|
|
|
void throttle_group_register_tgm(ThrottleGroupMember *tgm,
|
|
const char *groupname,
|
|
AioContext *ctx);
|
|
void throttle_group_unregister_tgm(ThrottleGroupMember *tgm);
|
|
void throttle_group_restart_tgm(ThrottleGroupMember *tgm);
|
|
|
|
void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm,
|
|
int64_t bytes,
|
|
ThrottleDirection direction);
|
|
void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,
|
|
AioContext *new_context);
|
|
void throttle_group_detach_aio_context(ThrottleGroupMember *tgm);
|
|
/*
|
|
* throttle_group_exists() must be called under the global
|
|
* mutex.
|
|
*/
|
|
bool throttle_group_exists(const char *name);
|
|
|
|
#endif
|