Skip to content

Commit 3f65357

Browse files
viviermstsirkin
authored andcommitted
vhost: Add stubs for the migration state transfer interface
Migration state transfer interface is only used by vhost-user-fs, so the interface needs to be defined only when vhost is built. But I need to use this interface with virtio-net and vhost is not always enabled, and to avoid undefined reference error during build, define stub functions for vhost_supports_device_state(), vhost_save_backend_state() and vhost_load_backend_state(). Cc: Hanna Czenczek <[email protected]> Signed-off-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 1ce979e commit 3f65357

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

include/hw/virtio/vhost.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,14 @@ static inline int vhost_reset_device(struct vhost_dev *hdev)
365365
* Returns true if the device supports these commands, and false if it
366366
* does not.
367367
*/
368+
#ifdef CONFIG_VHOST
368369
bool vhost_supports_device_state(struct vhost_dev *dev);
370+
#else
371+
static inline bool vhost_supports_device_state(struct vhost_dev *dev)
372+
{
373+
return false;
374+
}
375+
#endif
369376

370377
/**
371378
* vhost_set_device_state_fd(): Begin transfer of internal state from/to
@@ -448,7 +455,15 @@ int vhost_check_device_state(struct vhost_dev *dev, Error **errp);
448455
*
449456
* Returns 0 on success, and -errno otherwise.
450457
*/
458+
#ifdef CONFIG_VHOST
451459
int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **errp);
460+
#else
461+
static inline int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f,
462+
Error **errp)
463+
{
464+
return -ENOSYS;
465+
}
466+
#endif
452467

453468
/**
454469
* vhost_load_backend_state(): High-level function to load a vhost
@@ -465,6 +480,14 @@ int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **errp);
465480
*
466481
* Returns 0 on success, and -errno otherwise.
467482
*/
483+
#ifdef CONFIG_VHOST
468484
int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **errp);
485+
#else
486+
static inline int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f,
487+
Error **errp)
488+
{
489+
return -ENOSYS;
490+
}
491+
#endif
469492

470493
#endif

0 commit comments

Comments
 (0)