block.c (c88f1ffc19e38008a1c33ae039482a860aa7418c) block.c (6f7a3b535f0d48d138e43cadf13323f083bfb547)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 6750 unchanged lines hidden (view full) ---

6759 error_setg(errp, "The node %s does not have a child named %s",
6760 bdrv_get_device_or_node_name(parent_bs),
6761 bdrv_get_device_or_node_name(child->bs));
6762 return;
6763 }
6764
6765 parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
6766}
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 6750 unchanged lines hidden (view full) ---

6759 error_setg(errp, "The node %s does not have a child named %s",
6760 bdrv_get_device_or_node_name(parent_bs),
6761 bdrv_get_device_or_node_name(child->bs));
6762 return;
6763 }
6764
6765 parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
6766}
6767
6768int bdrv_make_empty(BdrvChild *c, Error **errp)
6769{
6770 BlockDriver *drv = c->bs->drv;
6771 int ret;
6772
6773 assert(c->perm & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED));
6774
6775 if (!drv->bdrv_make_empty) {
6776 error_setg(errp, "%s does not support emptying nodes",
6777 drv->format_name);
6778 return -ENOTSUP;
6779 }
6780
6781 ret = drv->bdrv_make_empty(c->bs);
6782 if (ret < 0) {
6783 error_setg_errno(errp, -ret, "Failed to empty %s",
6784 c->bs->filename);
6785 return ret;
6786 }
6787
6788 return 0;
6789}