Your implementation also ignores snapshots (which can contain further local disks). We already have some code to detect if a VM only uses shared resources in PVE::QemuMigrate::sync_disks(). And please note that a shared storage may not be available on all nodes, see PVE::QemuServer::check_storage_availability().