mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Feature #1727: Make snapshot size a long long, to be the same as image size
This commit is contained in:
parent
098060ef6a
commit
b233487967
@ -79,7 +79,7 @@ public:
|
||||
* @param size_mb of the snapshot (virtual size)
|
||||
* @return id of the new snapshot
|
||||
*/
|
||||
int create_snapshot(const string& name, unsigned int size_mb);
|
||||
int create_snapshot(const string& name, long long size_mb);
|
||||
|
||||
/**
|
||||
* Check if an snapshot can be deleted (no children, no active)
|
||||
@ -172,14 +172,14 @@ public:
|
||||
/**
|
||||
* @return total snapshot size (virtual) in mb
|
||||
*/
|
||||
unsigned int get_total_size() const;
|
||||
long long get_total_size() const;
|
||||
|
||||
/**
|
||||
* Get the size (virtual) in mb of the given snapshot
|
||||
* @param id of the snapshot
|
||||
* @return size or 0 if not found
|
||||
*/
|
||||
unsigned int get_snapshot_size(int id) const;
|
||||
long long get_snapshot_size(int id) const;
|
||||
|
||||
/**
|
||||
* Get Attribute from the given snapshot
|
||||
|
@ -508,7 +508,7 @@ void Image::disk_attribute( VectorAttribute * disk,
|
||||
dev_prefix = disk->vector_value("DEV_PREFIX");
|
||||
|
||||
long long size = -1;
|
||||
unsigned int snap_size;
|
||||
long long snap_size;
|
||||
|
||||
string template_target;
|
||||
string template_driver;
|
||||
|
@ -498,7 +498,7 @@ int ImageManager::delete_image(int iid, string& error_str)
|
||||
ipool->update(img);
|
||||
}
|
||||
|
||||
unsigned int snap_size = (img->get_snapshots()).get_total_size();
|
||||
long long snap_size = (img->get_snapshots()).get_total_size();
|
||||
|
||||
img->unlock();
|
||||
|
||||
|
@ -693,8 +693,8 @@ static void snap_delete_action(istringstream& is,
|
||||
ostringstream oss;
|
||||
string info;
|
||||
|
||||
unsigned int snap_size;
|
||||
int ds_id, uid, gid;
|
||||
long long snap_size;
|
||||
int ds_id, uid, gid;
|
||||
|
||||
Image * image = ipool->get(id, true);
|
||||
|
||||
@ -753,7 +753,7 @@ static void snap_delete_action(istringstream& is,
|
||||
Template quotas;
|
||||
|
||||
quotas.add("DATASTORE", ds_id);
|
||||
quotas.add("SIZE", (long long) snap_size);
|
||||
quotas.add("SIZE", snap_size);
|
||||
quotas.add("IMAGES",0 );
|
||||
|
||||
Quotas::ds_del(uid, gid, "as);
|
||||
@ -828,8 +828,8 @@ static void snap_flatten_action(istringstream& is,
|
||||
ostringstream oss;
|
||||
string info;
|
||||
|
||||
unsigned int snap_size;
|
||||
int ds_id, uid, gid;
|
||||
long long snap_size;
|
||||
int ds_id, uid, gid;
|
||||
|
||||
Image * image = ipool->get(id, true);
|
||||
|
||||
@ -876,7 +876,7 @@ static void snap_flatten_action(istringstream& is,
|
||||
Template quotas;
|
||||
|
||||
quotas.add("DATASTORE", ds_id);
|
||||
quotas.add("SIZE", (long long) snap_size);
|
||||
quotas.add("SIZE", snap_size);
|
||||
quotas.add("IMAGES",0 );
|
||||
|
||||
Quotas::ds_del(uid, gid, "as);
|
||||
|
@ -122,7 +122,7 @@ void Snapshots::init()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int Snapshots::create_snapshot(const string& name, unsigned int size_mb)
|
||||
int Snapshots::create_snapshot(const string& name, long long size_mb)
|
||||
{
|
||||
VectorAttribute * snapshot = new VectorAttribute("SNAPSHOT");
|
||||
|
||||
@ -285,9 +285,9 @@ string Snapshots::get_snapshot_attribute(int id, const char * name) const
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
unsigned int Snapshots::get_snapshot_size(int id) const
|
||||
long long Snapshots::get_snapshot_size(int id) const
|
||||
{
|
||||
unsigned int snap_size = 0;
|
||||
long long snap_size = 0;
|
||||
|
||||
const VectorAttribute * snapshot = get_snapshot(id);
|
||||
|
||||
@ -338,10 +338,10 @@ bool Snapshots::test_delete(int id, string& error) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
unsigned int Snapshots::get_total_size() const
|
||||
long long Snapshots::get_total_size() const
|
||||
{
|
||||
map<int, VectorAttribute *>::const_iterator it;
|
||||
unsigned int size_mb, total_mb = 0;
|
||||
long long size_mb, total_mb = 0;
|
||||
|
||||
for ( it = snapshot_pool.begin(); it != snapshot_pool.end(); it++)
|
||||
{
|
||||
|
@ -4277,7 +4277,7 @@ int VirtualMachine::get_snapshot_disk(int& ds_id, string& tm_mad,
|
||||
int VirtualMachine::new_disk_snapshot(int did, const string& name, string& error)
|
||||
{
|
||||
map<int, Snapshots *>::iterator it;
|
||||
unsigned int size_mb, snap_size;
|
||||
long long size_mb, snap_size;
|
||||
int snap_id;
|
||||
|
||||
VectorAttribute * disk;
|
||||
@ -4391,7 +4391,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id,
|
||||
Template **ds_quotas, Template **vm_quotas)
|
||||
{
|
||||
map<int, Snapshots *>::iterator it;
|
||||
unsigned int snap_size;
|
||||
long long snap_size;
|
||||
|
||||
VectorAttribute * delta_disk;
|
||||
VectorAttribute * disk = get_disk(did);
|
||||
@ -4411,7 +4411,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id,
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int ssize = it->second->get_snapshot_size(snap_id);
|
||||
long long ssize = it->second->get_snapshot_size(snap_id);
|
||||
|
||||
it->second->delete_snapshot(snap_id);
|
||||
|
||||
@ -4433,7 +4433,7 @@ void VirtualMachine::delete_disk_snapshot(int did, int snap_id,
|
||||
*ds_quotas = new Template();
|
||||
|
||||
(*ds_quotas)->add("DATASTORE", disk->vector_value("DATASTORE_ID"));
|
||||
(*ds_quotas)->add("SIZE", (long long) ssize);
|
||||
(*ds_quotas)->add("SIZE", ssize);
|
||||
(*ds_quotas)->add("IMAGES",0 );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user