<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
This RFC is to illustrate how attach disk to vm works and what the
API looks like.<br>
<br>
Use case:<br>
1. Guest wants to attach a volume which contains data.<br>
2. Guest is running out of storage space, attach an empty volume
to extend storage space.<br>
<br>
Flow:<br>
1. Create a *<b>float</b>* volume in a storage pool.(float means
this volume will not be deleted when vm's deleted, it is independent
from vm)<br>
Only *<b>float</b>* volume can be attached to vm.(to solve
volume ref count problem), All volumes created from storage tab is
float ones,<br>
because embedded storage is created when vm's created.<br>
<br>
POST /storagepools/pool-1/storagevolumes/ <br>
{'float': True, 'size':10G, 'name': 'a-float-volume'}<br>
GET /storagepools/pool-1/storagevolumes/a-float-volume<br>
{'float': True, 'ref_count':0, ...}<br>
<br>
2. On vm tab, list all availabe float volumes, currently only
support ref_count=0 volumes, select one and attach it to vm.<br>
GET
/storagepools/pool-1/storagevolumes?float=True&ref_count=0<br>
GET
/storagepools/pool-2/storagevolumes?float=True&ref_count=0<br>
...<br>
POST /vms/vm-1/storages/<br>
{'storagepool': 'pool-1', 'storagevolume':'a-float-volume',
'dev': 'hda', 'type':'disk'}<br>
<br>
3. Detaching a disk from a vm, NOTE: this will make no change to
content in the volume, just make it isolated from vm, if you want to
delete storage, go to storage tab.<br>
DELETE /vms/vm-1/storages/hda<br>
<br>
NOTE:<br>
This means we support disks from different storagepool, <br>
Temporarily we don't support share disk (in the future it will
be handled in a single feature). <br>
VM deletion will not involve float disk.<br>
As PCI hotplug already supported, we can add disk to a running
vm.<br>
<br>
Thanks to Mark Wu to contribute idea of float to solve volume life
cycle problem. Part of the inner implementation already be done by
Rodrigo and Daniel, I will try to extend their implementation for
hard disk.<br>
</body>
</html>