Skip to contentSkip to conversation

KVM: Move kvm_gmem_migrate_folio inside CONFIG_MIGRATION

PATCH In review 'Guanjun' 2 participants 2 messages Dec 11, 2023

Subsystems (2)
lore
Share & tools
lore

'Guanjun'

author
#0 lore raw

PATCH 1/1 KVM: Move kvm_gmem_migrate_folio inside CONFIG_MIGRATION

From: Guanjun <[email protected]>

'kvm_gmem_migrate_folio' is only used when CONFIG_MIGRATION is defined, And it will triggers the compiler warning about 'kvm_gmem_migrate_folio' defined but not used when CONFIG_MIGRATION isn't defined.

The compiler complained like that:
arch/x86/kvm/../../../virt/kvm/guest_memfd.c:262:12: error: ‘kvm_gmem_migrate_folio’ defined but not used [-Werror=unused-function]
262 | static int kvm_gmem_migrate_folio(struct address_space *mapping,

      |            ^~~~~~~~~~~~~~~~~~~~~~
Fixes a7800aa80ea4 (KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory)
---
 virt/kvm/guest_memfd.c | 2 ++
 1 file changed, 2 insertions(+)
virt/kvm/guest_memfd.c +2 -0
index 16d58806e913..62bb8a1a47d1 100644
@@ -259,6 +259,7 @@ void kvm_gmem_init(struct module *module)
 	kvm_gmem_fops.owner = module;
 }
 
+#ifdef CONFIG_MIGRATION
 static int kvm_gmem_migrate_folio(struct address_space *mapping,
 				  struct folio *dst, struct folio *src,
 				  enum migrate_mode mode)
@@ -266,6 +267,7 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping,
 	WARN_ON_ONCE(1);
 	return -EINVAL;
 }
+#endif
 
 static int kvm_gmem_error_folio(struct address_space *mapping,
 		struct folio *folio)
Signature · 1 line
2.39.3
#1 lore raw
Quoted 11 lines · Guanjun

From: Guanjun <[email protected]>

'kvm_gmem_migrate_folio' is only used when CONFIG_MIGRATION is defined, And it will triggers the compiler warning about 'kvm_gmem_migrate_folio' defined but not used when CONFIG_MIGRATION isn't defined.

The compiler complained like that:
arch/x86/kvm/../../../virt/kvm/guest_memfd.c:262:12: error: ‘kvm_gmem_migrate_folio’ defined but not used [-Werror=unused-function]
262 | static int kvm_gmem_migrate_folio(struct address_space *mapping,

      |            ^~~~~~~~~~~~~~~~~~~~~~

Already fixed, commit 80583d0cfd8f ("KVM: guest-memfd: fix unused-function warning") in kvm/next.

https://lore.kernel.org/all/[email protected]